I'm trying to build this wxWidgets sample program using Code::Blocks 12.11 but the build fails no matter what I try.
For example, the build log shows the following (the project is under X:\programming\c++\HelloWxWidgets):
mingw32-g++.exe -Wall -fexceptions -g -D_GNUWIN32_ -D_WXMSW_ -DwxUSE_UNICODE -D_WXDEBUG_ -IC:\libraries\wxWidgets-2.8.12.01\include -IC:\libraries\wxWidgets-2.8.12.01\contrib\include -IC:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\mswud -c X:\programming\c++\HelloWxWidgets\hworld2.cpp -o obj\Debug2\hworld2.o mingw32-g++.exe -LC:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib -o bin\Debug2\HelloWxWidgets.exe obj\Debug2\hworld2.o -static-libgcc C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o): In function
ZN8wxWindow6UpdateEv': C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:1643: undefined reference to
GdiFlush@0' C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o): In functionZNK8wxWindow13GetTextExtentERK8wxStringPiS3_S3_S3_PK6wxFont': C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:2132: undefined reference to
GetTextExtentPoint32W@16' C:\BuildAgent\work\wxPack\wxwidgets\build\msw/../../src/msw/window.cpp:2133: undefined reference to `GetTextMetricsW@8'
And these are some of the build messages that I get
C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o)||In function
ZN8wxWindow6UpdateEv':| C:\BuildAgent\work\wxPack\wxwidgets\build\msw\..\..\src\msw\window.cpp|1643|undefined reference to
GdiFlush@0'| C:\libraries\wxWidgets-2.8.12.01\lib\gcc_lib\libwxmsw28ud.a(monolib_window.o)||In functionZNK8wxWindow13GetTextExtentERK8wxStringPiS3_S3_S3_PK6wxFont':| C:\BuildAgent\work\wxPack\wxwidgets\build\msw\..\..\src\msw\window.cpp|2132|undefined reference to
GetTextExtentPoint32W@16'| C:\BuildAgent\work\wxPack\wxwidgets\build\msw....\src\msw\window.cpp|2133|undefined reference to `GetTextMetricsW@8'|
Here are the full build log and all of the build messages (by the way, I don't have a C:\BuildAgent directory)
I am using wxPack 2.8.12 (installed in C:\libraries\wxWidgets-2.8.12.01) and GCC 4.7.2 (installed separately from Code::Blocks in C:\mingw using mingw-get )
Here are the build options in Code::Blocks
Thank you in advance of your help :)
Alright, I finally managed to get it working :)
I'm posting here the procedure to follow if, like me, someone wanted to use wxWidgets in an (initially) console project under Code::Blocks. With this, anyone should be able to build/run at least this sample code in a Wind0ws environment:
Open a command prompt, wxWidgets needs to be built, I'll take the exemple of a statically-linked, monolithic, debug build that uses unicode (more infos here):
cd /D C:\libraries\wxWidgets-2.8.12\build\msw
mingw32-make -f makefile.gcc BUILD=debug SHARED=0 MONOLITHIC=1 UNICODE=1
:(mingw32-make will take some time to build the library)
Open Code::Blocks
[EDIT] wx/app.h should be included in addition to wx/wx.h
#include <wx/wx.h>
#include <wx/app.h>