Embedded Handbook/General/Introduction

== Introduction == Cross development has traditionally been a black art, requiring a lot of research, trial and error, and perseverance. Intrepid developers face a shortage of documentation and the lack of mature, comprehensive open source toolkits for multi-platform cross development. Ongoing work by the Embedded or Toolchain projects, and other contributors is yielding a Gentoo-based development platform that greatly simplifies cross development.

The toolchain
The term "toolchain" refers to the collection of packages used to build up a system (the "tools" which are used in the "chain" of events to take some input and produce some output). It is a loose definition in terms of what packages exactly are considered part of the toolchain, but for the sake of keeping things simple, we will consider the components that are needed to compile code into something fun and usable.

Your typical toolchain is therefore composed of the following:


 * - Essential utilities for handling binaries (includes assembler and linker).
 * - The GNU Compiler Collection (the C and C++ compiler).
 * or or  - The system C Library.
 * - Kernel headers needed by the system C Library.
 * - The GNU debugger.

All proper Gentoo systems have a toolchain installed as part of the base system. This toolchain is configured to build binaries native to its host platform.

In order to build binaries on the host system for a non-native platform you'll need a special toolchain - a so-called cross toolchain - which can target that particular platform. Gentoo provides a simple but powerful tool called for this purpose. Crossdev can build and install arbitrary GCC-supported cross toolchains on the host system, and because Gentoo installs toolchain files into target-specific directories the toolchains built by crossdev won't interfere with the host's native toolchain.

Toolchain tuples
All toolchains have a prefix (think CHOST ). More details on that can be found in the system tuples article.

Environment variables
Certain environment variables used by the Gentoo toolchain and Portage can thoroughly confuse developers inexperienced with cross development. The following table explains some tricky variables and provides sample values based on the cross development examples presented in this guide. See More terminology and variables (below) for more unusual variables and related concepts.

Say we have an desktop as our normal Gentoo machine and we have an  PDA we wanted to develop for, the above table would look like:

More terminology and variables

 * canadian cross
 * The process of building a cross-compiler which will run on a different machine from the one it was compiled on (CBUILD != CHOST && CHOST != CTARGET)


 * sysroot
 * The system root is where all the cross-compiler libraries and headers are installed. In other words, every library and header the cross-compiler needs to generate cross-compiled binaries are put into this directory. In theory, this means the toolchain is good enough. In practice, the cross-compiler often wants some of a packages's library dependencies, such as ncurses, installed into sysroot first.


 * hardfloat
 * The system has a hardware Floating Point Unit (FPU) to handle floating point math


 * softfloat
 * The system lacks a hardware FPU so all floating point operations are approximated with fixed point math


 * PIE
 * Position Independent Executable


 * PIC
 * Position Independent Code


 * CRT
 * C RunTime