This short tutorial will show you how to install and setup native toolchain on ESPRESSObin running Ubuntu 14.04 or Ubuntu 16.04. We will then use the toolchain to compile a simple "Hello World" program on the board. For this tutorial your ESPRESSObin should have Ubuntu flashed on it (as shown in Boot from removable storage - Ubuntu tutorial) as well as have basic routing enabled in order to download necessary components.
Installation
All we need to do in order to install the compiler, binutils and C library components of Ubuntu native toolchain is to connect to ESPRESSObin via console and there install build-essential package:
root@localhost:~# apt-get update root@localhost:~# apt-get upgrade root@localhost:~# apt-get install build-essential
With this command we will install Ubuntu native toolchain. In short, this includes:
- gcc and g++
- binutils
- libc6-dev
- other related utilities (make, dpkg-dev, patch and others)
You can view other installed utilities by running:
root@localhost:~# cat /usr/share/build-essential/essential-packages-list
In order to complete the toolchain installation we must also — if they are not installed already — install kernel headers for userspace development:
root@localhost:~# apt-get install linux-libc-dev
Optionally, the gdb debugger tool can also come in handy in such an environment. Install it with:
root@localhost:~# apt-get install gdb
and we are now all set up to write and compile our basic "Hello World" program. Open a text editor (we will name the file hello.c) and in it insert:
#include <stdio.h> int main() { printf("Hello, world!\n"); return 0; }
after which we save the file and exit editor. Finally, we compile the program with GCC as follows:
root@localhost:~# gcc -o hello hello.c
and run the program with:
root@localhost:~# ./hello Hello, world!
That is it, you have successfully run a simple "Hello, world" program using native Ubuntu toolchain.
Instructions from above can also be seen in the following video: