How to cross compile for Rapsberry Pi from Ubuntu

If you’re working on quite big development project that runs on RPi, you might be interested in speeding the build time.
Thus you have several options. For projects that don’t have lots of dependencies, you can use the official Raspberry Pi toolchain.
If you have some or more dependencies, some good tutorials will lead you to some rootfs or chroot technique.
Basically, it means – for the first – to have a copy of the RPi’s /lib and /usr folder somewhere locally on your building host.
The second means that you run commands in some kind of sandbox, where it can’t do much pain on your computer and it believe that the folder containing RPi’s usr and lib is a (fake)root.
Those two methods are boring and could lead to very strange behavior (since some lib inside /usr are linked to binaries inside /lib and the link are broken when copying (because the /lib on your system is not the Pi’s one).
Another solution is to emulate the Raspberry Pi inside Qemu for example, then setup a build environment there to build. But this could be longer than on a Pi itself…

For JamomaPureData project, I need to build on Travis-CI to test each commit and detect regression or so.
So having a light toolchain is indeed a real need for that.
I started with the officical toolchain and I added to it the library I need.
For doing so, I install all the libraries I need (libxml2-dev, libsndfile-dev and their deps) on my RPi, then I copy them one by one, include and lib to the toolchain folder.
In the official toolchain, the root folder is :arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/libc
You can also download the package, then dpkg -x *.deb in the folder, it could be faster but this could install uneeded file such as manual pages or programs.
Then my toolchain is here :

Then I can build for Raspberry Pi on !