Code::Blocks and Cross Compilers

From Code::Blocks
Revision as of 22:00, 26 June 2006 by Delete pYou (talk | contribs) (A few spelling and grammar fixes)

This Document will describe how to setup Code::Blocks to use it with a cross compiler. The idea is to create a easy way to develop software under a platform such as Linux, and create an executable for another platform e.g. Windows without booting to the native Operating System.

Linux -> Windows

This will describe how to setup your Linux Box to compile your code for the Windows platform. Depending on your Distribution, the installation of the needed packages can differ. Choose your Distribution:

Install mingw32 package

Ubuntu 6.06

First we will need the mingw32 package which is the cross compiler with some other tools. On my Ubuntu 6.06 I had to enable the universe packages to find it. Under Ubuntu 6.06 the mingw32 bin files are located in the /usr/bin directory. You will have to copy some of them to another directory, to make things work easier in Code::Blocks later. After installation, your system is already able to compile some small c/cpp source files which can be used directly under Windows.

apt-get install mingw32
cp /usr/bin/i586-mingw32msvc-* /usr/i586-mingw32msvc/bin/


someone could do that


someone could do that

Setup Code::Blocks to use the Cross Compiler

To let Code::Blocks know about your cross compiler you have to create a new compiler profile. Go to Settings->Compiler and Debugger Settings and create a copy of the current selected compiler. Type in a Name for the new profile e.g. cross_linux and hit enter.

Settings compiler debugger name.png 

Now you will have to change some directories for the new cross compiler. You will need to setup the directories for Compiler, Linker, and Resource Compiler. For every entry you have to put: /usr/i586-mingw32-msvc. The pictures below show how it should look like.

Settings compiler debugger compiler.png
Settings compiler debugger directories.png 

Settings compiler debugger Resource compiler.png

The last step is to tell Code::Blocks where and what your cross compiler binaries are. Just select the directory where you have copied all the compilers binaries ( /usr/i586-mingw32-msvc/ ) and setup the executables as shown in the picture below.

Settings compiler debugger programms.png

Now you can start a new or open an existing project and if you want to make a cross compilation for Windows platforms, just go to Project->Build Options and select your cross compiler. Remember that you will have to rebuild the whole project. You can test your build with wine.

have fun