Installing WxWin MinGW

From WxWiki

Jump to: navigation, search

Contents

[edit] How to install and use wxWidgets in combination with MinGW

[edit] General installation

NOTE:

MinGW is a g++-like compiler for win32. It works, however the executables it creates are rather BIG. In case you compile in DEBUG mode, the files become VERY BIG (>20 MB wxWidgets Minimal sample). With strip you can reduce the size, but it will always remain bigger than executables created with Visual Studio. In addition to that, Visual Studio seems to compile faster but I am not sure about this.

The reason why I installed and used MinGW is that I want to port my source to Linux. As the Visual Studio compiler accepts code that g++ won't this is a logical step.
  1. Download MinGW installer from http://mingw.sourceforge.net/ and install it.
  2. Download MSys installer for MinGW and install it (same webpage). Make sure to set the correct MinGW path in /etc/fstab.
  3. Now set PATH environment variable for your user. Go to Control Panel > System > Advanced > Environment Variables and add to the end of PATH: c:\MinGW\bin;c:\msys\1.0\bin (prepend a semicolon if needed).
  4. Check your PATH in a cmd shell by entering "path" and pressing ENTER.

For instructions on using Eclipse with MinGW, look at Eclipse.

[edit] Possible issues

(I don't know if it is the right place but I didn't find better)

[edit] undefined reference

While compiling your projects, you might get some "undefined reference" errors. In my case this was due to a wrong order in the g++ call : your static libs MUST be given before shared libs.

This might not work (please note the respective positions of "-lwx_mswXXXXXX" and "XXXXXXXXXXX/libXXXXXX.a") :

g++ -Wall -g -fexceptions -Wall -g -fexceptions -I/usr/local/lib/wx/include/msw-ansi-release-2.6 \
-I/usr/local/include/wx-2.6 -D__WXMSW__ -DWXUSINGDLL=1 -DNO_GCC_PRAGMA -o xpe.exe -Wl,--subsystem \
-Wl,windows -mwindows xpe.o xpemw.o  -L/usr/local/lib -mthreads -lwx_msw_xrc-2.6 -lwx_msw_qa-2.6 \
-lwx_msw_html-2.6 -lwx_msw_adv-2.6 -lwx_msw_core-2.6 -lwx_base_xml-2.6 -lwx_base_net-2.6 \
-lwx_base-2.6 ../src/components/codeeditor/libcodeeditor.a ../src/lib/liblogging.a ../src/lib/libstring.a
../src/components/codeeditor/libcodeeditor.a(tcodeeditor.o)(.text+0x169): In function `ZN11TCodeEditorC2EP8wxWindowiRK8wxString': C:/GNU/msys/1.0/home/Administrateur/xpe_project/src/components/codeeditor/tcodeeditor.cpp:45: undefined reference to `_imp__wxDefaultSize'
../src/components/codeeditor/libcodeeditor.a(tcodeeditor.o)(.text+0x2f4): C:/GNU/msys/1.0/home/Administrateur/xpe_project/src/components/codeeditor/tcodeeditor.c                                                        pp:46: undefined reference to `_imp___ZN22wxSystemSettingsNative9GetColourE14wxS

This correction should make it working (please note the respective positions of "-lwx_mswXXXXXX" and "XXXXXXXXXXX/libXXXXXX.a"):

g++ -Wall -g -fexceptions -Wall -g -fexceptions -I/usr/local/lib/wx/include/msw-ansi-release-2.6 \
-I/usr/local/include/wx-2.6 -D__WXMSW__ -DWXUSINGDLL=1 -DNO_GCC_PRAGMA -o xpe.exe -Wl,--subsystem \
-Wl,windows -mwindows xpe.o xpemw.o  ../src/components/codeeditor/libcodeeditor.a ../src/lib/liblogging.a \
../src/lib/libstring.a -L/usr/local/lib -mthreads -lwx_msw_xrc-2.6 -lwx_msw_qa-2.6 -lwx_msw_html-2.6 \
-lwx_msw_adv-2.6 -lwx_msw_core-2.6 -lwx_base_xml-2.6 -lwx_base_net-2.6 -lwx_base-2.6

[edit] Additional Information

An alternate how-to is available at http://max.berger.name/howto/wxWidgets/wxWidgets_MinGW.jsp

Personal tools