I want to cross-compile some stuff for my Raspberry, this is a (memo for me) tutorial to do that.
- Take crosstool-ng from here, here or here (the last two are mirror, use them only if the official website is not working)
- you need some dependencies:
apt-get install gcc gperf bison flex gawk libtool automake libncurses5-dev
- go into the crosstool-ng directory and:
.
/configure
--prefix=
path_where_to_
put_the_files
/make
make
install
cp
ct-ng.comp
/etc/bash_completion
.d/
- after I setup some bash vars in my .bashrc:
export WORKSPACE=~/workspace
export RASPBERRY=$WORKSPACE/raspberry
export CROSS_INST_PATH=$RASPBERRY/crosstool-ng/installer/
export PATH="$PATH:$CROSS_INST_PATH/bin" - and after to use them:
source ~/.bashrc
- go into path_where_to_put_the_files and:
ct-ng menuconfig
- the important options are:
- Paths and misc options
- (Important) Enable “Try features marked as EXPERIMENTAL“
- (Optional) Change “Prefix directory” (for example, you can put “
$RASPBERRY
/crosstool-ng/
x-tools/${CT_TARGET}” there)
- Target options
- (Important) Change “Target architecture” to “arm“
- (Important) Leave “Endianness” set to “Little endian“
- (Important) Leave “Bitness” set to “32-bit“
- Toolchain options
- (Nothing to do here, the defaults are fine)
- Operating system
- (Important) Change “Target OS” to “linux“
- Binary utilities
- (Optional) Change “binutils version” to “2.21.1a” or whichever is the latest that isn’t marked as experimental
- C compiler
- (Optional)”Show Linaro versions (EXPERIMENTAL)“. In the “gcc version” field, choose the “linaro-4.6-2012.04 (EXPERIMENTAL) compiler“. You’re free to choose a different one but this one works well. We do recommend the Linaro versions over the vanilla ones for the RPi
- (Optional) Enable “C++” under the group “*** Additional supported languages: ***” if you need g++ tool also built for your RPi toolchain
- Paths and misc options
- build the tool:
ct-ng build
after I setup some others bash vars (these is the final file):
export WORKSPACE=~/workspace
export RASPBERRY=$WORKSPACE/raspberry
export CROSS_CC_PATH=$RASPBERRY/crosstool-ng/x-tools/arm-unknown-linux-gnueabi/
export CROSS_INST_PATH=$RASPBERRY/crosstool-ng/installer/
export PATH="$PATH:$CROSS_CC_PATH/bin:$CROSS_INST_PATH/bin"after you are ready to compile, an example:
./autogen.sh --with-parameter-expansion-string-replace-capable-shell=/bin/bash --host=arm-unknown-linux-gnueabi --enable-static --prefix=$RASPBERRY/compile
Bibliography:
https://trac.ffmpeg.org/wiki/CompilationGuide/RaspberryPi
http://tech4research.wordpress.com/2014/03/04/installing-crosstool-ng-on-debian-7-4/