Crosstool-ng is an utility which can automate building of cross compiling toolchain for variety of architectures. Here I will show some steps to build for ARM architecture.

Needed packages, to be installed before using crosstool-ng

 $ sudo apt-get install autoconf automake libtool libexpat1-dev libncurses5-dev bison flex patch curl cvs texinfo build-essential subversion gawk python-dev gperf

Get latest Crosstool-ng

We can install this utility either globally or locally (inside the download directory). I choose latter option, after untarring and getting inside the newly generated directory follow commands as below.

 $ ./configure --enable-local 
 $ make 
 $ make install 

From now, building Cross compiling toolchain starts, be there at the same directory.

Type,

 $ ./ct-ng help 

for help.

Crosstool-ng comes with a set of ready-made configuration files for various typical setups:
Crosstool-ng calls them samples. They can be listed by using ./ct-ng list-samples.

We will use the arm-unknown-linux-uclibcgnueabi sample. It can be loaded by issuing:

 $ ./ct-ng arm-unknown-linux-uclibcgnueabi

Then, to refine the configuration, let’s run the menuconfig interface:

 $ ./ct-ng menuconfig

In Path and misc options:

  • Change Prefix directory to /usr/local/xtools/${CT_TARGET}. This is the place where the toolchain will be installed.
  • Change Maximum log level to see to DEBUG so that we can have more details on what happened during the build in case something went wrong.

In Toolchain options:

  • Set Tuple’s alias to arm-linux. This way, we will be able to use the compiler as arm-linux-gcc instead of arm-unknown-linux-uclibcgnueabi-gcc, which is much longer.

In Debug facilities:

  • Enable gdb, strace and ltrace. Remove the other options (dmalloc and duma). In gdb options, make sure that the Cross-gdb and Build a static gdbserver options are enabled; the other options are not needed.

Then, create the directory /usr/local/xtools/ and change its owner to your user, so that Crosstool-ng can write to it. Then, create the directory $HOME/src in which Crosstool-NG will save the tarballs it will download.

 $ ./ct-ng build

Wait, sometime to finish the process.

Enjoy….!

2 thoughts on “Steps to create Cross Compiling Toolchain using Crosstool-ng

Leave a comment