How to cross-build BeagleBone c++ sources to Linux executables.
The process isn't difficult, but there are some traps that I'll review here.
- ARM DS-5 development environment
- Linaro GCC ToolChain
- 7-Zip or another extractor that can create symbolic links
- Temporary admin rights on your Windows computer.
(assuming you have WinSCP, PuTTY and the drivers for your BeagleBoard running)
The community edition is ARM's free Eclipse-based IDE. Download and install.
After the download, you don't have a toolchain yet.
It's not hard to find GNU ARM compilers for bare metal. But getting a linux cross-compiler took some internet crawling.
Install Linaro cross-compiler Windows -> Linux ARM
Download a suitable archive.
For DS-5, I select a mingw32 hosted one with arm-linux-gnueabihf signature (big endian hard float).
The Debian image I have loaded is the latest at the moment I write this blog:
BeagleBoard.org Debian Image 2016-05-13
Linux beaglebone 4.4.9-ti-r25 #1 SMP Thu May 5 23:08:13 UTC 2016 armv7l GNU/Linux
It has the following gcc on board:
g++ (Debian 4.9.2-10) 4.9.2
The version of the toolchain that gave me the best compatibility with the Debian image is
It can be downloaded from here: http://snapshots.linaro.org/components/toolchain/binaries/4.9-2015.05-1-rc1/arm-linux-gnueabihf/gcc-linaro-4.9-2015.05-1…
Although the remainder of the blog always shows me using gcc 5.3.1, I switched down to 4.9.3 on Windows because my BB linux install didn't have all the libraries, and for this blog I wanted to stay as close to what's on the BB as possible.
Once downloaded, extract the tar from the tar.xz using 7-Zip (it's as easy as right-clicking on the .xz file and selecting "extract here").
for the next action, take care that you start 7-Zip as administrator.
Failing to do so will give you a corrupt toolchain install.
Without admin rights, 7-Zip can't create the symbolic links (just try it and check the log).
The result is that when you build your projects later, the linker will fail to find standard libraries.
You'll get cryptic messages like this.
libstdc++.so: file format not recognized;
Start 7-Zip as Administrator.
Open the .tar archive that you've generated in the previous step.
Press the Extract button. Navigate for the location where the toolchain can be saved.
That's it. The compiler, assembler, linker and other goodies are now installed.
Configure the Toolchain in DS-5
Start DS-5, and navigate to Window - Preferences menu.
Search DS-5 - Toolchains
Press the Add button, and navigate to the folder where you've just installed your chain.
(for me: D:\users\jancu\Documents\elektronica\arm\linaro\gcc-linaro-5.3-2016.02-i686-mingw32_arm-linux-gnueabihf)
Apply your changes, and restart DS-5 when asked.
Create a Project
This is what we've been waiting for all the time. Get our first project up.
Select File - New - C++ project
Select the Hello World C++ Project, and click the toolchain that you've just installed.
Press Next, and be inventive in the next screen.
Press Finish. Your project is created.
Right click on your project and build it.
If you followed these steps, you'll get good news:
Deploy and Run
Upload the binary file to your BB's home folder (do a binary transfer please) with WinSCP.
You can find thefile in the debug subfolder of your project.
(on my pc: D:\users\jancu\Documents\DS-5 Workspace\bbb_gnu_linux_cpp\Debug)
Log on to your BB via PuTTY. You should land in your home folder.
make the binary executable by launching this command:
chmod +x bbb_gnu_linux_helloworld
execute it by running:
If all is right, you should see the output on your terminal.
Thanks for playing!