sagargp
sagargp

Reputation: 1070

Cross-compiling C++11 code for Raspberry Pi

I'm trying to port a large project, which makes heavy use of C++11 features, to the Raspberry Pi. The project uses CMAKE and I'm using crosstool-ng for the cross-compiling. I installed dependencies on the Pi and copied them locally, and I've managed to get CMAKE to find those. Some of the code builds properly and produces ARM output. However, most of the code fails with confusing GCC output that I'm pretty sure has to do with C++11/template support. For example, I get errors like this:

These errors look like the ARM g++ compiler just doesn't like templates that much. The version of g++ being used is arm-unknown-linux-gnueabi-g++ (crosstool-NG 1.18.0) 4.7.3 20130102 (prerelease).

Can anyone point me in the right direction?

Edit: Here's what g++ looks like for one of the files in ps:

arm-unknown-linux-gnueabi-g++ -DprojectCore_EXPORTS -fPIC
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/freetype2
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/glib-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/lib/arm-linux-gnueabihf/glib-2.0/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/gdk-pixbuf-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/gtk-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/lib/arm-linux-gnueabihf/gtk-2.0/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/cairo
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/pango-1.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/atk-1.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/local/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/eigen3
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/flann
-I/home/sagar/workspace/project/include -std=c++0x -Wall -Werror -Wno-deprecated -fPIC -g -O4
-o CMakeFiles/projectCore.dir/src/project/Core/Memory/Array2D.C.o -c /home/sagar/workspace/project/src/project/Core/Memory/Array2D.C

Upvotes: 11

Views: 3773

Answers (2)

LogRCubed
LogRCubed

Reputation: 61

Let me start by saying I am not sure about the fix for this error. But I had seen a similar error while working with C++ in RPi for a large image processing code. I couldn't fix it by installing all the dependencies in time. Instead I ended up moving the entire code to cloud that was running windows server edition / windows 7 code where it compiled well. Just workaround idea if you are time bound!

Upvotes: 1

Delayer
Delayer

Reputation: 439

The only things I think are:

  • set -std=c++0x param to g++ compiler
  • link pthread (-lpthread)
  • you must be sure that you're compiling for armv6

Upvotes: 2

Related Questions