wiki:CrossCompiler

Cross-compiler

Principle

hackable:1 targets primarily hackable devices, which are often defined as embedded. They typically offer restricted resources compared to a modern desktop system. Therefore, it makes sense to develop and compile software on a powerful device, and then target the final device when packaging and assembling the distribution.

The cross-compiler is the development tool that fulfills this task, being able to compile code to a different platform than the one it runs on.

See also the  full definition on wikipedia.

Obtaining the cross-compiler

Stable version

hackable:1 provides a pre-configured environment to cross-compile applications, thanks to the  emdebian project. The latest, stable version is found here:  http://download.hackable1.org/cross/

It is versioned as 20xx.yz, where x is the current year, y the month, and z the day with a leading zero (eg 2009.407 for April 7th, 2009).

Daily builds

As of today, two builds are done daily from SVN, targeted for the Openmoko Freerunner [It seems actually, June 2011, theses archives aren't built any more, but you can access older versions here :  http://build.hackable1.org/images/old/Hackable1-Openmoko-Freerunner-cross-daily-amd64.tar.gz or  http://build.hackable1.org/images/old/Hackable1-Openmoko-Freerunner-cross-daily-i386.tar.gz]:

If you have any problem getting, creating or using the cross-compiler environnement, see the known problems section first.

From SVN

The cross-compiling environment is built like a regular hackable:1 image, like this (from the SVN root):

$ cd trunk/build
$ ./build.sh VENDOR=Openmoko MODEL=Freerunner PURPOSE=cross archive

If all is well, about half an hour later the file Hackable1-Openmoko-Freerunner-cross-200x.ya.tar.gz should be available.

The image generation process also supports generation of cross-compiler environments for a different architecture than the native one, thanks to the NATIVE_ARCH option:

$ uname -m
amd64
$ ./build.sh VENDOR=Openmoko MODEL=Freerunner PURPOSE=cross NATIVE_ARCH=i386 archive

Installing

As a chroot'd environment

The cross-compiler comes as a full, pre-configured Debian environment, with the cross-compiler environment already populated with hackable:1's packages. It is therefore possible to use it as a jailed environment within a native Linux system, using chroot like this:

$ mkdir cross
$ su -
Password:
# tar -xzvpf path/to/Hackable1-Openmoko-Freerunner-cross-200x.ya.tar.gz -C cross
# /usr/bin/env -i HOME=/root PATH=$PATH SHELL=$SHELL TERM=$TERM /usr/sbin/chroot cross /bin/bash

NB: if running the latter command via sudo do not forget to add sbin locations to PATH (PATH=/usr/sbin:/sbin:$PATH). Otherwise those binaries will be missing from the chrooted root environment.

In a virtual machine

Alternatively, the cross-compiler can work directly as a virtual machine. This is not always a trivial task, please refer first to your own virtualization software documentation to understand how to create virtual disk images for your system. Some howtos are available online:

Next step

Now you can set you environnment up: CrossCompiler/Setup