The major part of the potential target devices for GPE will not have an Intel x86 compatible CPU which most developers usually use on their development workstations. This and the fact that our typical target device has very limited harware capabilities are the reasons why we need special mechanisms to compile GPE libraries and applications to run on our target devices. Depending on the situation and your personal preference there are several methods to choose. We describe the most frequently used ones here. The examples assume that you compile for a device with an ARM CPU running Linux.
For a simple and fast start crosscompiling a GPE application get a copy of the prebuilt crosstoolchain for GPE from linuxtogo.org. Currently this reference toolchain is built using the OpenEmbedded build system. It is updated from time to time to supply newer compilers and updated libraries.
These toolchains are limited to some extend. Both the architecture of the computer the toolchain runs on and the architecture of the target system are fixed. Currently we have toochains wich run on Intel x86 based PCs running Linux and systems using an IBM PowerPC CPU running Linux. Both variants of toolchain create binaries for ARM CPU (StrongARM, Xscale, OMAP) based devices which are used on most mobile devices like PDAs.
To install the prebuilt toolchain you need to have root privileges on the PC you install it to. The installation itself is very easy: Change to the root ("/") directory and unpack the toolchain there:
$ tar xpjf sdk-package-archive.tar.bz2
Using the toolchain is easy as long as the software supports being crosscompiled properly. You need to have the compilers of the toolchain in your PATH environment. This is necessary to make sure all tools used for compiling the software find all the executable binaries shipped with the toolchain. To achieve this run:
$ export PATH=/usr/local/arm/oe/bin:$PATHYou can add this to your local .login or .bashrc file to have this setting in every shell you open.
Before using the toolchain for compiling you need to set the PKG_CONFIG_PATH environment variable to tell the pkgconfig tool where to find the correct information about the libraries shipped with the toolchain. The environment variable needs to point to the pkgconfig of the toolchains library directory. Do this:
$ export PKG_CONFIG_PATH=/usr/local/arm/oe/arm-linux/lib/pkgconfig/If you have more than one location you want to get libraries from, use ":" to separate multiple paths. You should not put this setting into .basrc, because you won't be able to compile natively without changing PKG_CONFIG_PATH anymore. You are now ready to start building your first application for the ARM architecture.
Compiling an application with the toolchain is very easy as long as all dependent libraries are part of the toolchain and crosscompiling works properly with the piece of software you intend to compile. The method to do this depends on the build tools which are used for this software. If the application is using autotools you need to pass some parameters to configure to tell it to create makefiles for crosscompiling. These parameters are the target prefix of the toolchain (in our case "arm-linux") and the destination prefix used on the target platform (usually "/usr"). Once configure created the necessary output files you can call make to start compiling. In most cases you just need to go to the source directory and run:
$ ./configure --host=arm-linux --prefix=/usr $ makeOf course you can add additional parameters to configure to influence the build process according to your needs.
If you want to compile software from CVS you need to run the script autogen.sh to create some parts of the build framework first. If the script is missing almost any autogen.sh from GPE CVS should do the trick.
If you need to compile one of the "classic" GPE applications not using autotools you need to pass the compiler and prefix to use to make directly. You need to set the variables CC to the compiler to use and PREFIX to the prefix for the software at least. If you want to build an ARM binary for Familiar Linux you would use:
$ make CC=arm-linux-gcc PREFIX=/usr
You can easily add software in the crosstoolchain or update existing ones. Compile and install it with /usr/local/arm/oe/arm-linux as PREFIX. If you update libraries using libtool it is a good idea to remove all *.la from /usr/local/arm/oe/arm-linux/lib.
Scratchbox is a very powerful virtual development environment which is able to build binaries for a different platform transparently and is even able to run these binaries in an emulated environment or by transfering them to a real device transparently. Scratchbox is available as packages for several distributions. For detailed information about installing Scratchbox refer to the Scratchbox project documentation.
Apart from the Scratchbox setup crosscompiling applications in Scratchbox is the same process like compiling natively. The only thing you need to do before is to select a target machine definition created during the install process. The fact that Scratchbox is able to execute the target binaries transparently avoids errors caused by broken autoconf tests which try to build and execute a binary because this will fail using a normal crosstoolchain. In addition to this you can configure Scratchbox to run these binaries on a real target device. This makes it possible to test and debug them on the target hardware in a very comfortable way. This is very important if the software makes use of special hardware features not present on development PC or if you port applications to a new hardware platform.
Scratchbox is very useful if you need libraries for native development which are incompatible with your host system (or each other). For some GPE applications which support the Hildon user interface from the Maemo project. This is very useful to switch from Hildon to plain GTK and back. You can do this by using Hildon inside of a native development target for Scratchbox and another target (or just your host system) for plain GTK.
Apart from the described methods you can always build your own toolchain, Debian crosstoolchain packages or use a User Mode Linux setup for crosscompiling. For a detailed description how to do this please refer to specialized documents.[ref]