Book Image

BeagleBone Essentials

By : Rodolfo Giometti
Book Image

BeagleBone Essentials

By: Rodolfo Giometti

Overview of this book

Table of Contents (18 chapters)
BeagleBone Essentials
About the Author
About the Reviewers

Native compilation versus cross-compilation

Programs for embedded systems based on ARM, MIPS and other non-PC architectures are traditionally written and compiled using a cross-compiler for that architecture on a host PC. This is the reason why we use a compiler that can generate the code for a foreign machine architecture, which means a different CPU instruction set from the compiler host's one.

For example, the BeagleBone Black is an ARM machine while (most probably) our host machine is an x86 PC (that is a normal PC), so if we try to compile a C program on our host machine, the generated code cannot be used on the BeagleBone Black and vice versa.

Let's verify this. Here is the classic Hello World program from The compiler section of Chapter 1, Installing the Developing System. Now we compile this program on our host machine using the following command:

$ make CFLAGS="-Wall -O2" helloworld
cc -Wall -O2    helloworld.c   -o helloworld

We can verify that this file is for the x86 (that is,...