For a project I’m working on, I’m developing a C++ application on the Raspberry Pi (Raspbian “wheezy”). I started working directly on the Rasppi but soon enough the compilation took really long to the point it wasn’t comfortable for me any more. So I decided to try to cross compile on my virtual Ubuntu on my computer. At the end this worked out pretty great, and I’m happy with the solution. I’m using Eclipse CDT as the IDE, which I’m not entirely happy about.

Most information about setting this up I found on the blog post from Hartaville. There are a few differences though. There is a step that makes the process a lot easier, and this isn’t mentioned in the blog itself, but only in the comments. So here I list the important broad steps:

  1. Download and Install Eclipse Juno
  2. Download Cross Compiling Toolchain ( )
    • I put it into /home/shin/raspberrypi
  3. Creating new Project in Eclipse:
    1. File -> New -> C++ Project
    2. choose “Cross GCC” as the Toolchain. <- This is the one step that is different
    3. Rest is normal, until to the “Cross GCC Command” page
      • Cross compiler prefix: prefix: arm-linux-gnueabihf-
      • Cross compiler path: /home/shin/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
    4. These steps should make sure that Eclipse will configure itself (include paths etc.

This should be enough to cross compile a basic project. For my project I also needed to use libraries that aren’t available in the cross toolchain. The next steps is how I made it compile with these libraries included.

  1. Download & Compile & Install the libraries on the Raspberry Pi
  2. Find the library files. (usually in /usr/lib/ or usr/local/lib)
    • copy to the workstation: /home/shin/raspberrypi/tools/usr/lib
  3. Find the include files (usually in /usr/inculde or usr/local/include)
    • copy to the workstation: /home/shin/raspberrypi/tools/usr/include
  4. Configure Eclipse: Project -> Properties -> C/C++ Build -> Settings
    • Cross G++ Compiler
      • Includes: -I: /home/shin/raspberrypi/usr/include
    • Cross G++ Linker
      • Libraries:
        • -l: thrift, wiringPi, boost_thread, pthread, gloox
        • -L: /home/shin/raspberrypi/usr/lib

In my project these options worked nice. I ran into the problem that the libraries itself needed other libraries included. In my case these were libcrypto, libssl and libz. With the following steps I included those:

  1. Find the libraries on the Raspberry Pi
    • In my case, they were in usr/lib/arm-linux-gnuebihf/
    • copy to the workstation: /home/shin/raspberrypi/tools/usr/wl
  2. Configure Eclipse: Project -> Properties -> C/C++ Build -> Settings
    • Cross G++ Linker
      • Miscellaneous:
        • Linker flags: -Wl,-rpath-link,/home/shin/raspberrypi/usr/wl

Well, this worked for me anyway. I also set-up Remote Debugging. Just follow instructions the instructions in the blog post from Hartaville.

Edit: corrected the path of the cross-compiler. Thanks reader in the comments