Friday, December 14, 2012

essential tools for cross-compiling linux

The goal here is to build a linux root filesystem on x86 for another architecture. In the very high level, you need following things:
1. a cross-compiler
2. bintuils, such as ld (linker), ar
3. However, in most of current open source packages, there is a 'configure' tool to determine the target system environment and build the actual Makefile. Many parameters are auto-detected based on the host system (like installed libraries and system configurations), through autotools "./configure" scripts. If you run the tool on x86 box, it will get the parameters of the x86 box, but not the targeted system. Therefore, you need some sort of sandbox to run the configure tool. Here, you need scratchbox which builds a cross-development environment. Scratchbox2 allows one to set up a "virtual" environment that will trick the autotools and executables into thinking that they are directly running on the embedded target with its configuration.
4. Even further, sometimes you need to run the binary in the built sysroot which means you need to run ppc binary on a x86 system, for example. In this case, you need qemu to run the binary in a chrooted environment. This has been described in my last post using dpkg as an example.

These are four essential tools you need to build a cross-compiled linux root filesystem. Once you have that, you can start downloading linux kernel sources as well as the other packages you need to start build your cross-compiled linux root filesystem.



No comments: