Anatomy of a toolchain
To get an idea of what is in a typical toolchain, I want to examine the crosstool-NG toolchain you have just created.
The toolchain is in the directory ~/x-tools/arm-cortex_a8-linux-gnueabihf/bin
. In there you will find the cross compiler, arm-cortex_a8-linux-gnueabihf-gcc
. To make use of it, you need to add the directory to your path using the following command:
$ PATH=~/x-tools/arm-cortex_a8-linux-gnueabihf/bin:$PATH
Now you can take a simple hello world
program that looks like this:
#include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[]) { printf ("Hello, world!\n"); return 0; }
And compile it like this:
$ arm-cortex_a8-linux-gnueabihf-gcc helloworld.c -o helloworld
You can confirm that it has been cross compiled by using the file
command to print the type of the file:
$ file helloworld helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.15.4, not stripped