不能 link wxWidgets 应用程序与 Code::Blocks / MinGW

Can't link wxWidgets app with Code::Blocks / MinGW

我有一个在 Eclipse 中构建的已经运行的 c++ + wxWidgets 应用程序,其中 wxWidgets 使用 MSYS 构建。

现在我想尝试不同的 IDE,例如 CodeLite 和 Code::Blocks,但是当我尝试它们时它们不起作用,因为我缺少它们想要的 build.cfg 文件。 所以我尝试了 "clean" 方法,备份了 wxWidgets 并使用 MinGW32-make 而不是 MSYS 再次构建它们。

现在尝试 Code:Block,我遇到了很多 "undefined reference" 错误,而且我不明白我做了什么或设置错了什么。

我会尽量在这里提供所有相关信息:

wxWidgets 的路径:

C:\SVILUPPO\TOOLS\wxWidgets

路径变量(相关部分)

PATH=C:\SVILUPPO\TOOLS\MinGW\bin;C:\SVILUPPO\TOOLS\MinGW\libexec\gcc\mingw32.8.1;

Mingw v4.8.1, make 版本

C:\SVILUPPO\TOOLS\wxWidgets>mingw32-make -v
GNU Make 3.82.90
Built for i686-pc-mingw32

wxWidgets 构建命令:

C:\SVILUPPO\TOOLS\wxWidgets\build\msw>mingw32-make -f makefile.gcc BUILD=debug UNICODE=1 SHARED=0 MONOLITHIC=1

Code::Block 构建日志:

-------------- Build: Debug in MyProject (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.cpp -o obj\Debug\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\fMainForm.cpp -o obj\Debug\src\fMainForm.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\GUI_MainForm.cpp -o obj\Debug\src\GUI_MainForm.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\My_Project.cpp -o obj\Debug\src\My_Project.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Prova_wxcrafter_bitmaps.cpp -o obj\Debug\src\Prova_wxcrafter_bitmaps.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib\mswud -IC:\SVILUPPO\TOOLS\wxWidgets\include -c C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp -o obj\Debug\src\Utilities\Utilities.o
C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp: In function 'char HexToChar(char*)':
C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp:73:66: warning: operation on 'HexString' may be undefined [-Wsequence-point]
  return (char)((AscHex(*HexString++) * 16) | AscHex(*HexString++));
                                                                  ^
C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp: In function 'byte HexToByte(char*)':
C:\Source\Codeblocks\Progetti\MyProject\MyProject\src\Utilities\Utilities.cpp:77:66: warning: operation on 'HexString' may be undefined [-Wsequence-point]
  return (byte)((AscHex(*HexString++) * 16) | AscHex(*HexString++));
                                                                  ^
mingw32-g++.exe -LC:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib -o bin\Debug\MyProject.exe obj\Debug\src\CustomControls\TAntiAliasedGauge\TAntiAliasedGauge.o obj\Debug\src\fMainForm.o obj\Debug\src\GUI_MainForm.o obj\Debug\src\My_Project.o obj\Debug\src\Prova_wxcrafter_bitmaps.o obj\Debug\src\Utilities\Utilities.o  -mthreads  -lwxmsw30ud -lwxpngd -lwxjpegd -lwxtiffd -lwxzlibd -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `StartElementHnd':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:637: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `TextHnd':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:687: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `StartCdataHnd':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:702: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `CommentHnd':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:727: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `PIHnd':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:742: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\lib\gcc_lib/libwxmsw30ud.a(monolib_xml.o): In function `ZN13wxXmlDocument4LoadER13wxInputStreamRK8wxStringi':
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:813: undefined reference to `XML_ParserCreate'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:826: undefined reference to `XML_SetUserData'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:827: undefined reference to `XML_SetElementHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:828: undefined reference to `XML_SetCharacterDataHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:829: undefined reference to `XML_SetCdataSectionHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:830: undefined reference to `XML_SetCommentHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:831: undefined reference to `XML_SetProcessingInstructionHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:832: undefined reference to `XML_SetDefaultHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:833: undefined reference to `XML_SetUnknownEncodingHandler'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:840: undefined reference to `XML_Parse'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:843: undefined reference to `XML_GetErrorCode'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:843: undefined reference to `XML_ErrorString'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:846: undefined reference to `XML_GetCurrentLineNumber'
C:\SVILUPPO\TOOLS\wxWidgets\build\msw/../../src/xml/xml.cpp:865: undefined reference to `XML_ParserFree'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 29 second(s))
19 error(s), 2 warning(s) (0 minute(s), 29 second(s))

我还尝试在 linker 设置中添加我在 arm-linux 下构建此代码时必须添加的其他库,但这些库文件不存在(我猜 '导致 MONOLITHIC 选项):

libwxmsw30ud_core.a
libwxmsw30ud_html.a
libwxmsw30ud_adv.a
libwxbase30ud_xml.a
libwxmsw30ud_richtext.a

最后,我不知道我最终应该如何 link 并从 Code::Block 调试我的源代码。

您需要 link 和 libwxexpat.a ,它是在您构建 wxWidgets 时创建的。