11

我正在尝试将一个大量使用 C++11 功能的大型项目移植到 Raspberry Pi。该项目使用 CMAKE,我使用 crosstool-ng 进行交叉编译。我在 Pi 上安装了依赖项并将它们复制到本地,并且我设法让 CMAKE 找到它们。一些代码可以正确构建并产生 ARM 输出。但是,大多数代码都因混淆 GCC 输出而失败,我很确定这与 C++11/模板支持有关。例如,我收到这样的错误:

  • error: 'mutex' in namespace 'std' does not name a type(有问题的文件包括 <thread>,如果我还包括 <mutex>,这个错误就会消失,这不是 x86 Ubuntu 的要求)

  • error: expected class-name before '{' token({ 之前的行是template<typename _Res> class __basic_future : public std::__future_base:)

  • error: '__result_type' does not name a type(这可能是由于上面的错误而发生的)

这些错误看起来像 ARM g++ 编译器只是不太喜欢模板。正在使用的 g++ 版本是arm-unknown-linux-gnueabi-g++ (crosstool-NG 1.18.0) 4.7.3 20130102 (prerelease).

谁能指出我正确的方向?

编辑:这是 g++ 中的一个文件的样子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
4

2 回答 2

2

我认为唯一的事情是:

  • -std=c++0x参数设置为g++ compiler
  • 链接 pthread ( -lpthread)
  • 你必须确定你正在编译armv6
于 2014-01-15T15:42:37.867 回答
1

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!

于 2014-01-20T09:41:48.423 回答