How to build Win32 wxWidgets application under Leopard

From WxWiki
Jump to navigation Jump to search

If you have developed some very nice application using C++ and wxWidgets on your favourite Mac under Leopard and wish to make Win32 build of it for your grandma who uses MS Windows please go on reading this HOWTO. We'll use MinGW crosscompiler to get the result.

First of all you have to make sure, you've installed command line development tools with your OS X and/or iPhone SDK's. When you install SDK it is called UNIX Development Support. Next you have to install wget [1]. It is required for the next step.


Now we have to download and build MinGW crosscompiler. I've used Cross-Hosted MinGW Build Tool [2] in Downloads section of At opened page you may find something like I've found: x86-mingw32-build-1.0-sh.tar.bz2 [3]. After downloading and unpacking it simply run and follow it's questions. Make sure the script is executable and don't forget to answer YES when C++ support is offered.

NOTE: due to some reason required files aren't available on all mirrors, so I've used mirror No.5 -

Actually I've used all defaults, except mirror and additional compiler support. If everything go ok, the script will download, build and install MinGW into your home folder. Mine was /Users/andrew/mingw32 (Please replace this path with one you've chosen during MinGW installation)

You may test some simple HelloWorld using /Users/andrew/mingw32/bin/i386-mingw32-g++ to compile. You have to keep mingwm10.dll file in your Windows system path or in the same folder with your EXE. Just copy it from /Users/andrew/mingw32/bin/ folder to your Windows PC together with hello.exe


If your test C++ HelloWorld compiles under Leopard and runs successfully under MS Windows you're really cool guy! So let's go on. Get latest wxAll package from and unpack to some folder. Then navigate there in terminal. You need to add our new compiler binary directory to system path to let wxWidgets configure script find it:


Then start configuration. I've used static build to make single EXE:

./configure --prefix=/Users/andrew/mingw32 --host=i386-mingw32 --disable-shared --enable-unicode

If everything go OK you'll get lots of output with similar lines at the end:

Configured wxWidgets 2.8.10 for `i386-pc-mingw32'
  Which GUI toolkit should wxWidgets use?                 msw
  Should wxWidgets be compiled into single library?       no
  Should wxWidgets be compiled in debug mode?             no
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets be compiled in Unicode mode?           yes
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.4      no
                                       wxWidgets 2.6      yes
  Which libraries should wxWidgets use?
                                       jpeg               builtin
                                       png                builtin
                                       regex              builtin
                                       tiff               builtin
                                       zlib               builtin
                                       odbc               no
                                       expat              builtin
                                       libmspack          no
                                       sdl                no

Next you should invoke make command to build wxWidgets. If you have multicore CPU (I do) the best is to load all cores at the same time:

make -j4

Wait for about 5-10 minutes while tons of code is being compiled and linked and invoke

make install


If you have done everything right and MinGW with wxWidgets are built and installed it is time to build your nice app for grandma :)

The most lazy way is to run next lines in your app source directory:

i386-mingw32-g++ *.cc *.cpp `/Users/andrew/mingw32/bin/wx-config --cxxflags --libs`
i386-mingw32-strip a.exe

It is important to write full path to wx-config utility explicitly because wxWidgets config utility comes with native OS X SDK and without that path you'll get OS X specific compiler and linker flags. Do not forget about mingwm10.dll

Congratulations! Your wxWidgets application now may be built without using PC and MS Windows. For corrections and comments please write me using my name at secondname dot org dot ua

Andrew Kosovich [4].