Cross Compiling on Linux for the Edison

Cross compile for Edison

Since I had a couple requests on how to cross-compile C/C++ programs for the Edison, I figured a quick post wouldn’t hurt. Note that I am using Ubuntu 14.04 (64-bit) for this example.

Download “SDK – Cross Compile Tools” from https://software.intel.com/en-us/iot/hardware/edison/downloads.

Unzip and run the installer. Note that the name of the files may change depending on the version of the SDK and your operating system.

unzip edison-sdk-linux64-ww25.5-15.zip
sh poky-edison-glibc-x86_64-edison-image-core2-32-toolchain-1.7.2.sh

Accept all defaults and let the SDK install.

Create a test program with nano hello.cpp (or your editor of choice) and enter:

#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
    return 0;
}

Set up the necessary environment variables and compiler with:

source /opt/poky-edison/1.7.2/environment-setup-core2-32-poky-linux

Cross-compile the example program with:

$CXX hello.cpp -o hello

Note that we’re using $CXX to refer to the g++ cross-compiler. Run echo $CXX to see what’s really going on. Now that we’ve compiled, transfer the executable over to the Edison. I used SCP:

scp hello root@192.168.2.15:/home/root

Log in to your Edison (serial terminal, SSH, etc.) and run it!

./hello

The information in this post came from this GitHub gist. Go there to see a more in-depth explanation, how to use gcc as well as g++, and set up the cross compile SDK on OSX and Windows.

4 thoughts on “Cross Compiling on Linux for the Edison

Leave a Reply

Your email address will not be published. Required fields are marked *