Development / Linux / Tools / Sponsored / Contributed

Compiler Tools for Embedded Linux Systems

10 Aug 2020 1:45pm, by

This is part of a series on using Linux for embedded systems. For a list of other articles in this series, check out the introductory post.

The Linux Foundation sponsored this post.

John Bonesio
John is a Linux Instructor at The Linux Foundation.

When working with embedded Linux systems, one of the first things you need is a cross compiler toolchain.

For the uninitiated, cross compiler tools are a set of tools (compiler, linker, assembler, etc.) that produce code in your compiled programs for a CPU instruction set different from your host machine’s CPU. For example, if you have a cross toolchain for ARM, you would compile your programs on your x86 laptop or desktop computer, and these programs would run on your embedded ARM system rather than on your laptop/desktop.

This article will refer to a lot of terms, such as kernels, bootloaders, root filesystems, and more. If these terms are unfamiliar to you, you can review previous articles in this series: Part 1, Part 2.

Using Existing Tools

There exist prebuilt cross embedded tools for ARM, PowerPC, MIPS, and more. If you are using a Debian based Linux distribution, such as Ubuntu, it’s likely you can just install them using Debian’s package system. For example:

sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

Other Linux distributions may also provide prebuilt compiler tools. These prebuilt tools often support C, C++, Objective C, Fortran, and more. And there are tools that support various hardware features in your embedded platform, such as the floating-point unit.

Using these prebuilt tools is probably the easiest way to get started building various software components of your embedded Linux system.

Building Your Own Tools

If you need more control, such as optimizing for size or making use of even more control over your processor features, you can build the compiler toolchain yourself.

Building the cross-compiler toolchain is pretty tricky. To build it correctly, it needs to be built three times to bootstrap the whole process — building a simple compiler to build libraries, then rebuilding it to use the libraries, etc. Most people don’t build cross-compiler tools by hand; instead, they use other tools to build them. There are a few tools available to build your own cross-compiler toolchain. Here are just a few of the more commonly used ones.


Crosstool-NG is a tool that builds cross toolchains. It will also build the standard libraries for your programs to link. You can find more information about crosstool-NG here.


Buildroot’s goal is to build an entire root filesystem — all the programs that go into /bin, /sbin, etc. As part of this process, Buildroot will also build the cross toolchain. Buildroot will build the cross toolchain, shared libraries and all the binary programs for the root filesystem, and will create a directory hierarchy of the root filesystem. Buildroot also optionally lets you build the kernel and the bootloader.

One advantage of Buildroot over crosstool-NG is that it will include all the shared libraries in the root filesystem — libraries that are needed if using dynamic linking. With crosstool-NG, these would need to be added to the root filesystem by some other process. You can find more information about Buildroot here.


The Yocto Project makes use of a tool called bitbake. Bitbake is a tool designed for building packages for embedded systems. These packages can be RPM packages, Debian packages, ipkg packages, or others. In order to create these packages, the Yocto Project will build the cross toolchain, and build a set of packages and their dependencies.

Yocto will also create an entire root filesystem that you can use directly or use to debug how the packages get installed. So like Buildroot, the Yocto Project will build the cross toolchain, shared and static libraries, the root filesystem, the Linux kernel, and the bootloader. Yocto will also create packages that can be installed individually. You can find more information about the Yocto Project here.

Once you have your cross compiler toolchain installed, you are set to build the various components of your embedded Linux system.

Feature image via Pixabay.

At this time, The New Stack does not allow comments directly on this website. We invite all readers who wish to discuss a story to visit us on Twitter or Facebook. We also welcome your news tips and feedback via email:

A newsletter digest of the week’s most important stories & analyses.