Compiling wxWidgets 3.0.0 to develop Code::Blocks (MSW)
Note, compiling Code::Blocks linked against the wxWidgets 3.0.0 is NOT ready for stable use; CodeBlocks developers are working hard to stabilize it, also patches are welcome to accelerate the migration
These are the instructions for compiling wxWidgets for use with Code::Blocks. They are primarily intended in preparation for compiling Code::Blocks itself but (hopefully) may also help installing wxWidgets for general development using that framework.
Although these instructions are targeted at the Windows operating system, it should be possible to apply them with slight adjustments to other platforms, since we make use of MinGW.
- 1 Installing MinGW
- 2 Installing the wxWidgets Source Code
- 3 Checking make Version
- 4 Building wxWidgets
- 5 Compiling Code::Blocks
Directions to install MinGW for Code::Blocks can be found here. MinGW installation
Installing the wxWidgets Source Code
The wxWidgets 3.0.0 distribution can be found at the wxWidgets download site. (Note that there is also a winhelp file available.) You can choose between an installer and a zip file. You can just get the zip file because the installer is also a zipped version.
If you use the plain zip version, make sure to unzip using the full path. Otherwise the directories won't be created correctly.
NOTE: For the remainder of these instructions we call the wxWidgets directory <WXWIN>. You have to change it to your corresponding directory (e.g. "c:\wxMSW-3.0.0\wxWidgets-3.0.0").
NOTE: You do not need MSYS. Furthermore, you cannot have MSYS in your path, or the wxWidgets compilation will fail. Thus, if you have MSYS installed, ensure that <MSYS>\bin is not in your path before compiling wxWidgets. wxWidgets must be compiled from a "regular" command line (like cmd.exe), not from a Unix-like shell. The same problem could arise if Cygwin is in the path.
NOTE: For the remainder of these instructions we call the MinGW directory <MINGW>. You have to change it to your corresponding directory (e.g. "C:\MinGW").
Checking make Version
If you didn't install MinGW yourself you have to ensure you are using a recent enough version of the make utility. Open a command prompt and type:
cd <MINGW>\bin mingw32-make -v
The version should read 3.80 or higher.
Changing Directory and Setting Path
To compile wxWidgets, open the command prompt window and change to the wxWidgets directory:
cd /d <WXWIN>\build\msw
NOTE: This is normally SET PATH=C:\MingGW\bin
Cleaning wxWidgets Code
Now clean up the source:
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" clean
NOTE: Make sure you use exactly the same options for this step and for the build step below. The clean target uses these variables and only cleans the specified version of the generated object and library files. (It will not clean the intended files if these variables are not identical.)
NOTE: If you still have problems with compiling after cleaning, you could try to manually remove the gcc_dll directory under the build\msw directory. This directory is the place where the object files are stored.
Building wxWidgets Code
When everything is clean you can start compiling wxWidgets:
mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport" >log.txt 2>&1
NOTE: If you want another version of wxWidgets (debug or non-Unicode) you still have to make sure you build a MONOLITHIC version (one big DLL) for linking Code::Blocks.
NOTE: If you are building wx3.0.2 with GCC 4.9.x or GCC 5.x, you will get compiler error, thus a patch is need, see discussion here: Build C::B against wx3.02 with gcc 5.2 under Windows
NOTE: There is an compiler option needed if you want to suppress the compiler warnings, see: Re: TDM-GCC 5 series (Latest: 5.1.0 - 2015-06-28)
Patience. This step takes time. Make sure there was no compilation error before you continue.
Code::Blocks project to use
No patches are needed to compile Code::Blocks with wxWidgets 3.0, just use the project/workspace-files with the _wx30 in the name and call update30.bat to update the resources.
That does not mean, that everything runs absolutely bug-free, but we are working on it.
As always patches are welcome.
Setting up paths
Before finally compiling Code::Blocks itself, you need to setup the paths:
- Open the Code::Blocks project (CodeBlocks_wx30.cbp).
- It will ask you to define a Global variable named "wx30"
- Set the path to where you have wxWidgets installed (e.g. "c:\wxMSW-3.0.0\wxWidgets-3.0.0").
- Set the global variable cb_release_type to "-g". (no quote is needed when your enter the text)
- Compile Code::Blocks.
NOTE: A zip.exe file should be in your PATH, so they can run post steps correctly, see 1.6 zip.exe for some details about zip.exe
Post compilation steps
When the compilation process is finished, simply run the update30.bat script. It will ensure that all resource files Code::Blocks uses are in the right place and up to date.
- Forum discussion:Re: wxWidgets 3.0 and Code::Blocks files question?
- Installing Code::Blocks from source on Windows
- Note that PCH is disabled in Codeblocks_wx30.cbp, because it cause GCC build error (a bug in GCC 4.8.x Bug 56926 – Crash (without ICE) while compiling Boost.Math), see discussions here: Re: wxWidgets 3.0 and Code::Blocks files question? and Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1. As of 2015-09-27, there is a gcc suite which have PCH crash issue fixed, see forum post Re: Patches for Compiling Code::Blocks against wxWidgets 3.0 using MinGW GCC 4.8.1