This post includes important information for our developing process. I will show you 2 different ways to compile an application to run on BeagleBone Black and help you to decide which one is better.
1. Application compiling ways
We can refresh our mind about compiling by checking my post about microcontroller-software-development-process.

As you can see on above picture, there are 2 types of toolchains:
- Native Compiling Toolchain: if that toolchain works on PC machine, then output image can be run only on PC machine with same OS. Result is also same as on BeagleBone Black.
- Cross Compiling Toolchain: this toolchain works on PC but its output image can be run on other machine, in here is BeagleBone Black.
Then you can also see, we have 2 ways to compile image that can be run on BeagleBone Black now.
2. Native Compiling
a. What is Native Compiling?
For easy understanding, native compiling means we use a compiler that works on BeagleBone Black (that running Linux for Arm based of BBB hardware), then the compiled software will also be run on the same one.
b. How to Native Compile?
To make it more clear, I will show you an example about using BBB for both compiling and running an application.
- Access your BBB by using debug port or SSH showed in setup-beaglebone-black-working-environment
- First, check your compiler version that running on BBB
debian@beaglebone:~$ gcc --version gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- Next we need to see what the library that gcc is using
debian@beaglebone:~$ gcc -print-libgcc-file-name /usr/lib/gcc/arm-linux-gnueabihf/6/libgcc.a
- Now we can see arm-linux-gnueabihf is actually the toolchain set used by gcc
debian@beaglebone:~$ arm-linux-gnueabihf-gcc --version arm-linux-gnueabihf-gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- Finish the checking step, now we move to implementation
- Create a hello.c file:
debian@beaglebone:~$ vi hello.c
- Press “i” to start inserting your code in Vi:
#include <stdio.h> int main(void) { printf("Hello BBB using native compiling\n"); return 0; }
- Press “Esc” -> “:wq” to save file
- Now use native compiler in BBB to build output application:
debian@beaglebone:~$ gcc -o hello hello.c
- Check hello binary as the application built by native compiler
debian@beaglebone:~$ ls -la hello -rwxr-xr-x 1 debian debian 8344 Jan 20 06:10 hello
- Run the application on BBB and check the result
debian@beaglebone:~$ ./hello Hello BBB using native compiling
We really developed an application running on BBB.
3. Native Compiling Advantage And Disadvantage
As you can see we can implement an application very fast by using native compiling without further installation. This helps us to verify how application work on BBB and save our time in developing process.
However compiling a source is not the reason why BBB was born. It is an embedded device, so all of its capabilities should be used for real action, then someone can modify or even delete unnecessary part such as compiling toolchain on BBB.
And despite the powerful configuration, BBB still can not be the competitor of Host PC. Then when working on big project or task, using a Host PC to compile image really save our time. That is the reason we should learn Cross-Compiling.
See you in my next post.
Really enjoyed this blog post. Thanks Again. Fantastic. Lissy Laird Keslie
Hello There. I found your weblog using msn. This is a very neatly written article. Blinni Samuele Jennings
I really like looking through a post that will make men and women think. Also, many thanks for allowing for me to comment! Elli Far Finley