Prerequitive

This guide assume ,basic knowledge of Kernel(uImage) and RootFS and
prior knowledge of C programming .

Introduction to Toolchain

Toolchain are Chain or set of programming tools for building an apps , it could include following :

Editor for writing program

Assembler

Compiler

Preprocessor

Linker loader

Debugger

Binutils etc.

Toolchain Type

a)Native toolchain

Native toolchains are tools which makes binaries for the environment where toolchain itself is being run.i.e Host and target are same platform.
This type of Compilation process is called Native compilation .Meaning that the program is compiled on same platform where it has to be run. Similar to normal PC based program ,they are compiled and run on same machine.

e.g. Normal GCC Toolchain in x86 Linux machine is a Native toolchain.

It is much easier to program using this method as it doesn’t involve any Makefile changes.

Earlier embedded devices had very less memory and space and also limited supports of Input-output peripherals, hence Native compilation was not possible or very difficult.
But with the advent of powerful embedded ARM processor its now possible to make application on the platform itself. Same can be done in Hawkboard too.Yet compilation will be slower as compare to that in x86 machine.

b)Croos Toolchain

Toolchain which are used to compile the application that will run of different machine(architecture) .This is usually used for embedded apps (e.g ARM programming)
You program/compile in x86 environment and run in ARM Board. This type of compiling is called cross compiling.

Since native compilation is either not possible or very slow ,Cross compilation present a better alternative for faster development .Only drawback is to properly set build environment and Makefiles.

c)Hybrid Toolchain

It similar to native toolchain,but infact toolchain run in virtualised environment
on Host.Simple example is QEMU -ARM Running on X86 Linux & you are developing application
on this Virtual environment.

This has advantage of both Native and Cross compilation.Speed of cross compilation & Ease
of Native development.

Various solution exists, One is scratchbox ,another is ChrootEABI feature in Ubuntu.

d)Canadian Toolchain
The Canadian Cross is a technique for building cross compilers for other machines. Given three machines A, B,
and C, one uses machine A to build a cross compiler that runs on machine B to create executables for machine C.
Not practiced normally .

Native Toolchain & Compilation

There are various ways solution to compile the application natively on hawkboard.

1. Using Ubuntu Rootfs

Rootstock script in Ubuntu provides a easy way of making Root Filesystem
give gcc,vi,g++ as seed parameter to rootstock command and you will have
a GNU Toolchain inside the rootfs.

Extract and properly export the path of native-compiler-armv5l/bin and you can compile the apps on hawkboard.
use [Static linking] instead of dynamic linking .

gcc hello-world.c -static

This toolchain uses uClibc instead of standard glibc as library
which better suited for embedded environment.

Cross Toolchain & Compilation

There are Lots of readily available tool chains that you can extract and
start compiling apps on x86 architecture and finally load and run on hawkboard.

1.Codesourcery Toolchain

This is the most common toolchain used for OMAP.Codesourcery provides
both a free version and licensed release toolchain.
Free version can be downloaded from the link below

2.ImpactLinux Toolchain

3.Cross Toolchain by Fedora Arm Project

If you are using a Fedora as host environment than easiest way is to use Fedora ARM Toolchain.
Fedora provides arm toolchain packages for i386 and x86_64 that are built from the same sources as the Fedora native toolchain packages (binutils, gcc, gdb, glibc.)
To install this toolchain on your Fedora machine, do:

Buildroot is a set of Makefiles and patches that makes it easy to generate a cross-compilation toolchain and root filesystem for your target Linux system using the uClibc C library. Buildroot is useful mainly for people working with small or embedded system.

Scratchbox is a cross-compilation toolkit designed to make embedded Linux application development easier. It also provides a full set of tools to integrate and cross-compile an entire Linux distribution.

Now you can build/test packages etc, the chroot works like any other x86 chroot on your system as long as you have the qemu-arm-static package installed with the advantage that you can make use of all resources your host system provides (CPU speed, RAM, diskspeed etc)

Appendix

C libraries - uClibc & GlibC

While most of the Embedded Devices uses Size optimize Library uClibc.
Hence Statically Linked binaries using uClibc are much smaller than Glibc Linked Binary

Below shows a comparison of Hello-World Program Statically combined on two Libraries

Left uses Codesoucery Toolchain that uses Glibc (634kB)

Right uses Impactlinux Toolchain that uses uClibc (22kB)

Static Vs Dynamic Linking

Static linking is to combine an application program with the parts of various library routines it uses.

Main advantage in using this is that you don't care about dependencies ,binary will be able to run on different

machine.Also Statically Linked binary runs faster

Disadvantage is the RAM & Flash is wasted by duplicating the same library code in every static linked process,as
statically linked file is significantly of greater size.

to Statically link libraries to Code add -Static to gcc.

gcc -static Hello-world.c

Dynamic Linking
Dynamic linking involves loading the subroutines of a library into an application program at load time or runtime, rather than linking them in at compile time; the subroutines remain as separate files on disk.Libraries can be called by multiple programs.
This saves lots of space ,only drawback being porting of application you need to have depended libraries copied to another system
when you are porting your apps.

Normally a program when compiled is dynamically linked ,this can be check using ldd & File commmand