July 30, 2021

Impact & Learning

Learn to impact

GNU compiler & debugger tools

Read Time:3 Minute, 24 Second

The GNU compiler and debugger collection provides a variety of tools to develop any type of software project, from compiling libraries for the Linux kernel, to developing client-level applications.

The compilation cycle requires tools that allow users not only to generate object codes, but also require a construction of elements that allow embedded system developers to use kernel modules and other libraries to create their systems. So we show some of these tools, which you may use every day or you didn’t know. Let us!

GCC compiler

The gcc compiler has been the favorite tool to use, due to its portability and being free code, it is also the most used to compile code in C, C ++, etc. Its level to compile code at medium level allows to develop embedded systems and services that use kernel modules and also process information obtained from POSIX hardware and threads.

The compiler is preconfigured to use the GNU C Standard library, however you can also use alternate libraries such as the lightweight uClibc library.

To compile a code in C language, as long as you do not use an external library or additional modules, you can do it easily with this command line instruction:

gcc example.c -o example

In the previous line example.c is the file with the source code in C, and with the option –o we obtain an executable output file, example in this case, which is the product obtained from the compilation of our source code.

If an external library is required, it must be specified at the time of compilation, for example if you want to compile the POSIX pthreads library the compilation would be:

gcc example.c -o example -pthread

GDB Debugger

GDB is a tool to debug code through communications (TCP or serial) on a host running GDB. This is an external program, which has the ability to listen to the events of the application and catch the exceptions when appearing to show them to the user. It has a language gamma that supports, from C, Assembler, Go, Ada, Objective-C, etc.


It is a very useful open source tool to develop Operating Systems with Linux kernel. BusyBox is a collection of essential programs for all kernel, low weight and highly configurable. So it is a key component for the development of Operating Systems or Embedded. Much of the applications contained in the /bin and /sbin directories are contained here.

Automake, Autoconf and Make

It is an open source tool that automatically generates a Makefile. It makes use of Autoconf to build an environment to build a project or module.

To create a module with automake, we first create our source code, which in this example hello world style, will be called hello.c

#include <config.h>
#include <stdio.h>
int main (void) {
   puts ("Hello World!");        
   puts ("This package is part of" PACKAGE_STRING "."); 
   return 0; 

Now we execute autoscan, with this a configure.scan file is generated, which will have to be modified to configure.ac:

mv configure.scan configure.ac

We edit configure.ac, so it must contain the following content:

AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_FILES([Makefile src/Makefile])

We now create a Makefile.am file, containing only the following:


And also create the src/Makefile.am file, with the following:

bin_PROGRAMS = hello
hello_SOURCES = hello.c

Then we write the following commands in the shell, to generate the configuration file that will contain the commands to create the environment that later will invoke the built compilations.

automake --add-missing

Finally, the construction of the executable is done through the configured one, as follows:

# If you want to create a tarball to distribute
make dist

Make performs the injection of dependencies and compilations necessary to create the executable for the specific environment.