Details Of Cross-Compiling

A cross-compile toolchain exists of a set of tools: a compiler, linker, assembler, debugger and a C library. A cross-compile toolchain runs on your host system and creates native binaries for your target system. A cross-compile toolchain is basically created in six steps:

  1. Compile the binutils package for your target
  2. Compile a static C compiler for your target
  3. Get and prepare the Kernel and C library headers of your target system
  4. Compile and install a C library for your target
  5. Compile and install a full C/C++ compiler
  6. Compile and install the GNU debugger

The cross-compile toolchain is created in staging_dir_$(cpu_arch)[*]. All the tools running on the host, but used to create, analyze or debug for the target are kept in this directory. All addon headers and libraries are installed to this directory.

If you want to compile a simple application without using the ADK, just use the compiler directly (e.g. compiling a MIPS Little Endian application):

[label=compile a simple application with the cross-compiler]
./staging_dir_mipsel/bin/mipsel-freewrt-uclibc-gcc -o myapp myapp.c

Check with the tool file if you got a MIPS binary:

[label=check the binary with \app{file}]
$ file myapp
myapp: ELF 32-bit LSB MIPS-I executable, MIPS, version 1 (SYSV), dynamically
linked (uses shared libs), not stripped