Thursday, March 6, 2014

How to cross compile for Raspberry Pi using Code::Blocks on Linux

In my privious post I described how I managed to build a cross compiler in Ubuntu for a Raspberry Pi. To compile I used a terminal command. But I want to use a IDE. On Linux I use Code::Blocks for now.

So we have to add a custom compiler to Code::Blocks. Go to
Settings --> Compiler ... --> Global compiler settings
Select the GNU CCC Compiler and click Copy. Give your new cross compiler a meaningful name.


Select your created compiler and go to Toolchain executables. Specify under Compiler's installation directory the path where you keep you cross compiler. For me the path looks like this:
/home/christian/Programming/x-tools/arm-unknown-linux-gnueabi

IMPORTANT: Don't specify the path to the bin directory like in the add-to-$PATH tutorial !!!

After that change the compilers and linkers so it looks like this:


Hit OK and create a new project. Select Console application.


Select your language and your directory where you want to save the project ...


Select your just created compiler...


After that you see already a Hello-World-Program. Try to build it. If it works yout get this notification.


Now we want to check if the cross compiler worked. Copy from your project directory the created file in /bin/debug in your home directory on your RPi. On your RPi (I used ssh) open the terminal and type
 ./ FILENAME  
If you see a "Hello World!" then your cross compiler works !

Program versions:
OS: Ubuntu 12.04 LTS
crosstool-ng 1.19.0
Code::Blocks 10.05

No comments:

Post a Comment