我如何使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说这部分代码是问题所在:
希望能对您有所帮助,在此先感谢!
最佳答案
您需要始终保留DEBUG_FLAG=1
,否则断言将无法编译。
这就是MSW的install.txt中所说的内容:
指定wxWidgets中的调试支持级别。请注意,
独立于BUILD和DEBUG_INFO选项。默认情况下,始终设置为1表示已启用>调试支持:
编译成代码(默认情况下它们处于非活动状态
应用程序的版本,但可以启用),wxLogDebug()和
wxLogTrace()可用,并且定义了WXDEBUG。设置为
0设置时完全禁用wxWidgets中的所有调试代码
它为2甚至可以启用耗时的断言并检查哪个
被认为不适合生产环境。
关于c++ - 为什么wxWidgets不能与Code::Blocks + minGW一起使用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12059616/