Difference between revisions of "Compiling wxWidgets 3.0.0 to develop Code::Blocks (MSW)"

From CodeBlocks
Jump to: navigation, search
(Patching Code::Blocks to using 2.9 instead of 2.8)
(No difference)

Revision as of 06:16, 6 January 2014

Note, the wxWidgets 2.9.0 release is a development release NOT intended for production use.

Note, compiling Code::Blocks linked against the wxWidgets 2.9.0 is NOT ready for stable use; it crashes and fails to compile from time to time.

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.9.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-2.9.0\wxWidgets-2.9.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.

Building wxWidgets

Editing the values to be used in wx/setup.h

Note, changing the value of wxUSE_STC prevents error compiling Code::Blocks because it has its own custom version of STC.

Open the folder <WXWIN>\include\wx\msw\
If the file setup.h does not exist copy the file setup0.h to setup.h
With an text editor open <WXWIN>\include\wx\msw\setup.h
Change "#define wxUSE_STC 1" to "#define wxUSE_STC 0"
Save the changes

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 MONOLITHIC=1 SHARED=1 UNICODE=1 USE_STC=0 USE_PROPGRID=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. (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_msw 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 MONOLITHIC=1 SHARED=1 UNICODE=1 USE_STC=0 USE_PROPGRID=1 BUILD=release

NOTE: These options are not the officially-supported Code::Blocks options because there is no official options for wxWidgets 2.9. The option of "USE_STC=0" is needed because Code::Blocks has its own customized version of it; and, if both exists it will cause errors building Code::Blocks plugins. The option "USE_PROPGRID=1" is used to help building plugins that depend on wxPropertyGrid. 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.

Patience. This step takes time. Make sure there was no compilation error before you continue.

Compiling Code::Blocks

Patching Code::Blocks to using 2.9 instead of 2.8

No patches are needed to compile Code::Blocks with wxWidgets 2.9, just use the project/workspace-files with the _wx29 in the name and call update29,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.cbp).
  • It will ask you to define a Global variable
  • Set the path to where you have wxWidgets installed (e.g. "c:\wxMSW-2.9.0\wxWidgets-2.9.0").
  • 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.