Cross-compiling for the OSWALD using Gentoo
Gentoo provides a nice setup for cross-compiling software for various target architectures including ARM, which the OSWALD uses. This page outlines the basic instructions necessary for an experienced Gentoo user to get a working cross-compiler that can build binaries for the OSWALD. For the official Gentoo embedded documentation see the Gentoo Embedded Handbook.
First, install the crossdev package. Note that it's best to use the latest testing version available so place sys-devel/crossdev in your package.keywords before running:
Building a cross-compiling toolchain
Next, use crossdev to build a cross-compile toolchain for the OSWALD. This can be using the following command:
sudo crossdev -t armv7a-unknown-linux-gnueabi
By default, crossdev will use the latest stable versions of the toolchain packages. If this does not work, you should manually select which versions to use for the various toolchain packages -- use the help output from crossdev to figure out how to do this.
Cross-compiling with portage
If crossdev successfully built a cross-compile toolchain, it should be located in the /usr/armv7a-unknown-linux-gnueabi directory. In order to use the cross-compiler it is easiest to use some wrapper scripts provided by the crossdev package that setup the necessary environment variables. If you didn't setup the emerge-wrapper already you can do so now by running the following command:
sudo emerge-wrapper --init
Then you should be able to use either of the following commands to cross-compile packages using portage:
emerge-wrapper --target armv7a-unknown-linux-gnueabi <emerge options>
Also, the various compilers can be manually running using by prefixing the command with the CTARGET. For example,
should invoke the selected gcc compiler for the armv7a-unknown-linux-gnueabi cross-compile toolchain.
Common problems when cross-compiling
The following problems are often seen when cross-compiling using Gentoo's crossdev environment or in other UNIX-based cross-compile environments.
libtool linking errors
wrong gcc errors
configure test errors