静态链接wxWidgets时的引用错误

时间:2012-09-16 14:47:31

标签: c++ mingw wxwidgets static-libraries premake

我在构建脚本中使用this Premake4 script for wxWidgets

wx_config {Unicode="yes", Version="2.9", Libs="core,aui,media,html", WindowsCompiler="gcc", Static="yes"}

但CodeBlocks和MinGW分别输出许多错误:

wx\lib\gcc_lib/libwxbase29u.a(baselib_filename.o):filename.cpp:(.text+0x5371): undefined reference to `CoCreateInstance@20'
wx\lib\gcc_lib/libwxbase29u.a(baselib_filename.o):filename.cpp:(.text+0x5390): undefined reference to `IID_IPersistFile'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7cc9): undefined reference to `wxEVT_POWER_SUSPEND_CANCEL'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7cf9): undefined reference to `vtable for wxPowerEvent'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7d55): undefined reference to `wxEVT_POWER_SUSPENDED'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7d61): undefined reference to `wxEVT_POWER_SUSPENDING'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7d6d): undefined reference to `wxEVT_POWER_RESUME'
wx\lib\gcc_lib/libwxmsw29u_core.a(corelib_window.o):window.cpp:(.text+0x7f18): undefined reference to `vtable for wxPowerEvent'
...

您可以在此处查看所有链接器错误:http://pastebin.com/UGSRg4DX

有人在wxWidgets错误报告(链接丢失)中提到库顺序导致此问题。但他没有说要先放哪个库。

1 个答案:

答案 0 :(得分:2)

这看起来与this one完全相同。即你需要按照正确的顺序将库放在预制脚本中:aui,media,html,core(重要的是“核心”是最后一个)。另外,我不知道它是否隐含地附加了,但通常你最后也需要“基础”。