Compiling wxWidgets 2.8.6 to develop Code::Blocks (MSW)

From Code::Blocks
Revision as of 10:31, 3 October 2007 by Stahta01 (talk | contribs)

Note: This is an copy of Compiling wxWidgets 2.6.2 to develop Code::Blocks (MSW) https://wiki.codeblocks.org/index.php?title=Compiling_wxWidgets_2.6.2_to_develop_Code::Blocks_%28MSW%29

That is being updated for wxWidgets 2.8.6

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.

Installing MinGW

Directions to install MinGW for Code::Blocks can be found here. MinGW installation

Installing the wxWidgets source code

The wxWidgets 2.6.3 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.

The patches wxWidgets 2.6.3 distribution can be found at the wxWidgets download site.

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-2.6.3-1\wxWidgets-2.6.3").

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 because minGW mingw32-make with version 3.81 sometimes has problems building wxWidgets.

Checking patch version

In order to patch the wxWidgets using diffs we need to verify that patch exists and is the correct version. Note: Not all patches of wxWidgets use diffs; some just require copying files into the wxWidgets folder.

Open a command prompt and type:

cd <MINGW>\bin
patch -v

The version should read 2.5, if not recognized then you need to get the patch command. A way to do this is by getting UnxUtils.zip which contains patch 2.5. Unzip UnxUtils.zip to a temp folder then copy patch.exe to your <MINGW>\bin folder.

NOTE: The version 2.5.9 of patch from GnuWin32 seems to have a problem with unified diffs and can NOT be used to apply diffs to wxWidgets.

UnxUtils

UnxUtils is ports of the most often used Unix utilities. Note that some tools in UnxUtils are quite a bit outdated, so make sure you do not overwrite already existing MinGW files with their UnxUtils counterparts.

Patching wxWidgets

How to apply patch 2

Download wxWidgets-2.6.3-Patch-2.zip
What I do is extract the zip into the folder called wxWidgets-2.6.3-Patch-2.
Then, I copy the folder src in wxWidgets-2.6.3-Patch-2 into the folder <WXWIN> overwriting the old copies of the files.

How to apply diffs

Now it is time to patch wxWidgets, open the command prompt and change to the wxWidgets directory:

cd <WXWIN>

Building wxWidgets

Now it is time to compile wxWidgets, open the command prompt and change to the wxWidgets directory:

cd <WXWIN>\build\msw
SET PATH=<MINGW>\bin;<MINGW>\mingw32\bin

NOTE: This is normally SET PATH=C:\MingGW\bin;C:\MingGW\mingw32\bin

Now the first thing to do is to clean up the source:

mingw32-make -f makefile.gcc MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release 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 (so it will actually 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_msw directory under the build\msw directory. This directory is the place where the object files are stored.

When everything is clean you can start actually compiling wxWidgets:

mingw32-make -f makefile.gcc  MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release

NOTE: These options are the officially supported Code::Blocks options. 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 against.

Now you can get a cup of coffee or do something else because this step takes some time. Make sure there was no compilation error before you continue.

NOTE: If you're having errors because of libjpeg, you might want to look at this patch

Compiling Code::Blocks

Setting up paths

Before finally compiling Code::Blocks itself, you need to setup the paths:

  • Open the Code::Blocks project (CodeBlocks.cbp).
  • It will ask you to define a Global variable
  • Set the path to where you have wxWidgets installed (e.g. "c:\wxWidgets-2.6.3").
  • Compile Code::Blocks.

Post compilation steps

When the compilation process is finished, simply run the update.bat script. It will ensure that all resource files Code::Blocks uses are in the right place and up to date.