I am eager to get compiling and I would like to use the latest and the best tools.
In fact, the latest and best tools do not need to be built by yourself. On the Raspberry Pi Tool GitHub Repository you will find the X86_64
and x686
toolchains for cross-compiling software.
I recommend using the x86-linux64-cross-arm-linux-hardfp
toolchain, as that will compile for Hard Floating Point, which will result in a much faster system.
$ arm-bcm2708hardfp-linux-gnueabi-gcc --version
arm-bcm2708-linux-gnueabi-gcc-4.5.1 (Broadcom-2708) 4.5.1
Copyright (C) 2010 Free Software Foundation, Inc.
Note: If you are using an existing kernel then you will have to use the toolchain that matches the kernel. HardFP applications will not work on a SoftFP kernel.
To use the toolchain simply check out the repository:
git clone https://github.com/raspberrypi/tools.git --depth 1
The --depth
parameter will mean that you don't have to wait for the repository history to be downloaded as well (since we wont be using it).
Then add the binaries to your PATH variable:
export PATH=~/tools/arm-bcm2708/x86-linux64-cross-arm-linux-hardfp/bin:$PATH
Or to persist the PATH:
echo "export PATH=~/tools/arm-bcm2708/x86-linux64-cross-arm-linux-hardfp/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
To compile with the tool chain you can now add the CROSS_COMPILE
parameter. For example, when running make
:
make CROSS_COMPILE=arm-bcm2708hardfp-linux-gnueabi-
Or to make this easier, you can save the variable to bashrc
again:
echo "export TARGET=arm-bcm2708hardfp-linux-gnueabi" >> ~/.bashrc
source ~/.bashrc
and now use the variable when compiling:
make CROSS_COMPILE=${TARGET}