【问题标题】:Why won't wxWidgets work with Code::Blocks + minGW?为什么 wxWidgets 不能与 Code::Blocks + minGW 一起使用?
【发布时间】:2012-08-21 16:57:20
【问题描述】:

如何让 wxWidgets 2.9.4 与 Code::Blocks + MinGW 一起工作?我已经构建了库(仅发布)并编写了一些代码。当我构建它没有事件表时,它可以正常工作,但使用它们会引发错误。

当有事件表时,这里是构建消息的转储:

obj\Debug\main.o||In function `_ZN21wxEventTableEntryBaseC2EiiP14wxEventFunctorP8wxObject':|
C:\wxWidgets\include\wx\event.h|2870|undefined reference to `_wxTheAssertHandler'|
C:\wxWidgets\include\wx\event.h|2871|undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'|
obj\Debug\main.o||In function `_ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EC1EMS3_FvRS4_EPS3_':|
C:\wxWidgets\include\wx\event.h|374|undefined reference to `_wxTheAssertHandler'|
C:\wxWidgets\include\wx\event.h|374|undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'|
obj\Debug\main.o||In function `_ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EclEPS3_RS4_':|
C:\wxWidgets\include\wx\event.h|392|undefined reference to `_wxTheAssertHandler'|
C:\wxWidgets\include\wx\event.h|392|undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'|
||=== Build finished: 6 errors, 0 warnings ===|

和另一个构建日志:

-------------- Build: Debug in G1BC ---------------

Compiling: main.cpp
Linking executable: bin\Debug\G1BC.exe
obj\Debug\main.o: In function `_ZN21wxEventTableEntryBaseC2EiiP14wxEventFunctorP8wxObject':
C:/wxWidgets/include/wx/event.h:2870: undefined reference to `_wxTheAssertHandler'
C:/wxWidgets/include/wx/event.h:2871: undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'
obj\Debug\main.o: In function `_ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EC1EMS3_FvRS4_EPS3_':
C:/wxWidgets/include/wx/event.h:374: undefined reference to `_wxTheAssertHandler'
C:/wxWidgets/include/wx/event.h:374: undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'
obj\Debug\main.o: In function `_ZN20wxEventFunctorMethodI14wxEventTypeTagI14wxCommandEventE12wxEvtHandler7wxEventS3_EclEPS3_RS4_':
C:/wxWidgets/include/wx/event.h:392: undefined reference to `_wxTheAssertHandler'
C:/wxWidgets/include/wx/event.h:392: undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
6 errors, 0 warnings

Code::Blocks 说这段代码是问题所在:

希望您能提供帮助,在此先感谢!

【问题讨论】:

  • 尝试在调试中构建 wxWidgets,因为您得到的所有错误都是针对仅在调试中的断言函数。
  • 标记区域没有问题。问题出在makefile中。你缺少图书馆。这些都是链接器错误。

标签: c++ wxwidgets codeblocks


【解决方案1】:

您需要始终将DEBUG_FLAG=1 保留为那个,否则断言将无法编译。

这是 MSW 的 install.txt 中所说的:

指定 wxWidgets 中的调试支持级别。请注意,这 独立于 BUILD 和 DEBUG_INFO 选项。 默认情况下始终设置为 1,这意味着 > 调试支持已启用:断言是 编译到代码中(默认情况下它们在发布时处于非活动状态 构建应用程序,但可以启用), wxLogDebug() 和 wxLogTrace() 可用并且定义了WXDEBUG。将其设置为 0 在设置时完全禁用 wxWidgets 中的所有调试代码 它到 2 甚至可以启用耗时的断言并检查哪个 被认为不适合生产环境。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    相关资源
    最近更新 更多