Translation(s): none


Installing a Cross Compiler

This document will help you obtain Debian packages of a cross-compilation toolchain. It is based on a HOWTO by Josh Triplett, with his kind permission.

Note that most cross-toolchain combinations you might actually want within Debian are built by the Embedded Debian Project, so you may well just be able to apt-get what you need on their Toolchains page: http://www.emdebian.org/crosstools.html

We'll say that again: MOST PEOPLE SHOULDN'T BE BUILDING THEIR OWN CROSS-TOOLCHAIN - THEY SHOULD JUST INSTALL A PRE-BUILT ONE LIKE ANY OTHER PACKAGE.

To install a prebuilt cross compiler

What if I have an Ubuntu system or want to do multiarch-style crossbuilding?

If you have an Ubuntu system, cross-toolchains are included (from 10.10/Maverick onwards). From 12.10/Quantal onwards there is a crossbuild-essential-<arch> convenience package to install cross toolchains, cross-pkgconfig and (multiarch) cross-libc. So simply installing crossbuild-essential-armhf, or crossbuild-essential-arm64 will get you all the stuff you need. (multiarch for the architecture you want to build for must be enabled, with dpkg --add-architecture <arch> (e.g. armhf))

Prior to quantal there are just cross-toolchain packages which install the cross-toolchain and default compiler links. apt-get install arm-linux-gnueabi-gcc (for armel) or arm-linux-gnueabihf-gcc (for armhf). These toolchains search multiarch library and header paths by default so are suitable for multiarch crossbuilding.

For other architectures, or if you have a Debian system you should get toolchains from Emdebian. These toolchains search in the 'dpkg-cross' cross-lib/headers paths, not the new multiarch paths, so are not very useful for multiarch cross-building.

Debian multiarch-ready cross-toolchains for armhf and armel are available here: http://emdebian.org/~thibg/repo/pool/main/g/gcc-4.7/ Work is underway to integrate cross-toolchains properly into debian: multiarch-ready Debian cross-toolchains.

Installing cross-toolchains from Emdebian

Add the Emdebian keyring from Debian before you start.

apt-get install emdebian-archive-keyring

Add two apt sources, one for your normal mirror and one for Emdebian:

deb http://ftp.XX.debian.org/debian squeeze main
deb http://www.emdebian.org/debian squeeze main

Create a new file in /etc/apt/sources.list.d/ with the above lines.

Use whatever is your normal Debian mirror for the first line which brings in some dependencies which are no longer in Wheezy or unstable.

Now just install your toolchain, e.g. for armel:

apt-get update
apt-get install g++-4.4-arm-linux-gnueabi

Emdebian also maintain scripts which effectively do what this page describes. Take a look at the buildcross package from Debian experimental, which will build a whole range of toolchains.

Most users do not need to build the cross-compiler


CategoryEmdebian