静态链接 wxWidgets 时的引用错误

Reference errors when linking wxWidgets statically

本文关键字:引用 错误 链接 wxWidgets 静态      更新时间:2023-10-16

我在构建脚本中将这个Premake4脚本用于wxWidgets:

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

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

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

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

有人在wxWidgets错误报告(链接丢失)中提到库顺序导致了这个问题。但他没有说必须首先放置哪个图书馆。

这看起来像是与此完全相同的问题。 也就是说,您需要以正确的顺序将库放入预制脚本中:aui,media,html,core(重要的是"核心"是最后一个)。另外,我不知道它是否隐式附加,但通常您还需要在最后附加"base"。