compiler targets the BeagleBone. To get the Pi cross
compiler tools from a Linux terminal, you would issue git
clone git:// github.com/raspberrypi/tools.git. This will clone
the tools into your selected directory. You can also use a
Linux terminal and https to gain access to the Pi cross
compiler tools using https://github.com/raspberrypi/tools.git.
I Hate Hello World Programs
So, our very first cross compiled C++ BeagleBone
program will fall under the project name of walk TheDog.
Instead of “Hello World!” our program will display
“Design Cycle Walks the Dog.” Let’s put Eclipse to work
beginning with Screenshot 2.
The Hello World C++ Project selection will force us to
use the Linux GCC toolchain. This selection will also write
a simple C++ skeleton Hello World-like program
for us. We can control some of the content of the
pregenerated C++ program that Eclipse will
produce by filling in the blanks in Screenshot 3.
Most of the text will end up behind comment
characters in the main file. The greeting field will
be transferred to the main function call.
The results of my interaction in Screenshot 3
can be seen in Screenshot 4. The iostream
declaration enables the use of the standard output
object cout. Declaring using namespace std;
eliminates the need to explicitly define the
standard namespace for cout using a namespace
prefix (std::cout) in the code.
If we were to build the C++ code right now, it
would not run on our BeagleBone. That’s because the
Linux GCC toolchain that is being referenced belongs to
the ThinkPad’s Ubuntu distribution and would produce
Ubuntu i386 binaries instead of ARM binaries. To cross
compile, we’ve got to point to and use the ARM include
directories and libraries. We must also make sure we use
the correct ARM compilation commands.
ARMing the Compilers
The default command for the GCC C++ compiler in
Screenshot 5 was g++. As you can see, I’ve changed it to
ADVANCED TECHNIQUES FOR DESIGN ENGINEERS
April 2014 69
; Screenshot 2. Our anti-Hello World code begins here.
Note the Linux GCC toolchain has been assigned. Don't
be fooled as this is not yet explicitly pointing at the ARM
GCC toolchain. Note the project location
; Screenshot 3. I fiddled with every entry except the
Source. Most of the fields will end up as description
; Screenshot 4. Everything I changed in Screenshot 3 can be seen
here. This is just about as basic as a C++ program can get.