[wxWidgets] Compiling wxWidgets for MS Windows

Posted on Dec 30, 2014

1. Get the latest source code from https://www.wxwidgets.org/downloads/ (ver 3.0.2 as of Dec 30, 2014) and unzip it somewhere.

2. Go to ./build/msw

3. Compile
– For MS Visual Studio, find a solution file for your VS version (e.g., wx_vc12.sln) and build.
– For MinGW, open a cmd window and set the bin folder of MinGW in the beginning of your PATH environment variable, like the following example.

set "PATH = C:\GNU\mingw64\bin;%path%"

Then, run the following commands, depending on the version you want to build.

@ release DLL
mkdir ..\..\lib\gcc_dll\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0

@ debug DLL
mkdir ..\..\lib\gcc_dll\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0

@ release static LIB
mkdir ..\..\lib\gcc_lib\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0

@ debug static LIB
mkdir ..\..\lib\gcc_lib\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0

* Additional tips

1. The makefile.gcc included in the 3.0.2 version somehow does not create the destination folder correctly, so I added mkdir to the above build commands.

2. C++11 note: If you want to compile wxWidgets in C++11 mode, you currently have to use -std=gnu++11 switch as -std=c++11 disables some extensions that wxWidgets relies on. I.e. please use CXXFLAGS=”-std=gnu++11″.

3. The default value for MSLU is supposed to be 0. Without defining it explicitly, however, the resulting library keeps looking for some functions from MSLU, when compiled with MinGW.
MSLU: MS Layer for Unicode. It is only necessary for Windows 95.

4. When you build an application with the static LIB version of wxWidgets, you may want to add -static to your link option. Otherwise, your application would still ask some DLLs from MinGW, not being completely static.