The art of cross compiling
Having a working cross toolchain is the starting point of a journey, not the end of it. At some point, you will want to begin cross compiling the various tools, applications, and libraries that you need on your target. Many of them will be open source packages—each of which has its own method of compiling and its own peculiarities. There are some common build systems, including:
- Pure
makefiles
, where the toolchain is usually controlled by the make variableCROSS_COMPILE
- The GNU build system known as Autotools
- CMake (https://cmake.org/)
I will cover only the first two here since these are the ones needed for even a basic embedded Linux system. For CMake, there are some excellent resources on the CMake website referenced in the preceding point.
Simple makefiles
Some important packages are very simple to cross compile, including the Linux kernel, the U-Boot bootloader, and BusyBox. For each of these, you only need to put the toolchain prefix in the make variable CROSS_COMPILE...