Search by Tags

Native Compilation


Article updated at 28 Oct 2017
Compare with Revision

Subscribe for this article updates

Please note that cross compilation is usually very much the preferred solution. Disk space, memory and CPU resources are limited on an embedded device, all those factors make it not an ideal development environment. Should you still feel like wanting to attempt native compilation it can be done as follows:

For V2.5 images one has to add an additional package feed to get also packages compiled for arm instruction set. The following adds that feed:

root@colibri-vf:~# echo "src/gz base2" > /etc/opkg/base2-feed.conf

Now install the development packages:

root@colibri-vf:~# opkg update
root@colibri-vf:~# opkg install packagegroup-sdk-target
root@colibri-vf:~# gcc --version
gcc (Linaro GCC 4.9-2015.03) 4.9.3 20150311 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

This should work fine out-of-the-box on a decently resourceful module. On a Colibri T20 256 MB module you might have to lower the memory consumption by disabling the graphical desktop or even down-scale on carveout memory usage. On a Colibri VF50 you might simply not have enough resources to install above let alone compile much of anything useful really.

That said after having all that configured/installed properly the native compilation environment is ready, e.g. compiling a simple helloworld program:

root@colibri-vf:~# echo "#include <stdio.h>" > hello.c
root@colibri-vf:~# echo "int main (void) { printf(\"Hello World\n\"); return 0; }" >> hello.c
root@colibri-vf:~# gcc hello.c -o hello
root@colibri-vf:~# ./hello
Hello World

Note: Our V2.6 series image ship a newer version of the GCC support library libgcc1. Opkg does not downgrade the library, and complains with the following error:

Not downgrading libgcc1 from linaro-5.2-r2015.11-2 to linaro-5.2-r2015.11.0 on root.

You can install the libgcc1 support library from the opkg feeds (which seem to work fine) using this command:

root@colibri-vf:~# opkg install --force-downgrade libgcc1

Note: Starting with V2.7 beta 1 we modified libc to work on Apalis/Colibri T20/T30 despite us relying on an ancient Linux kernel version from NVIDIA's L4T. Please make sure to hold on to our libc version as follows to avoid it getting replaced leading to FATAL: kernel too old:

root@colibri-t30:~# opkg flag hold libc6
Setting flags for package libc6 to hold.