Guide How To Cross Compile Application For Beagle Bone Black From PC With Debian
Install The ToolChain
Since we are using Debian, we have access to the Debian repositories.
We can use standard apt-get command to install ARM based toolchain for BBB.
Type the following commands in Debian terminal:
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
gcc-arm-linux-gnueabihf is the cross-toolchain package for the armhf architecture. This toolchain implies the EABI generated by the gcc -mfloat-abi = hard option.
‘hf’ means hard-float which indicates that the compiler and its underlying libraries are using hardware floating point instructions rather than a software implementation of floating point such as fixed point software implementations.
To install also the g++ compiler for C++ type the following command in Debian terminal:
sudo apt-get install g++-arm-linux-gnueabihf
To check if the toolchain was successfully installed type:
arm-linux-gnueabihf-gcc --version
You should see the version of gcc compiler like:
arm-linux-gnueabihf-gcc (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 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.
Create Test Application
Create new file with code
#include <iostream>
using namespace std;
int main() {
cout << "!!!Hello World from BBB!!!" << endl; // prints !!!Hello World from BBB!!!
return 0;
}
and save as testBBB.cpp
Make the application:
arm-linux-gnueabihf-g++ testBBB.cpp -o testBBB
Copy the compiled application testBBB to your Beagle Bone Black module:
scp testBBB debian@192.168.7.2:/home/debian
Run the program at BBB board
From the BBB terminal run the application:
debian@beaglebone:~$ ./testBBB
!!!Hello World from BBB!!!