我正在尝试将一个大型项目移植到 Raspberry Pi 上,该项目大量使用了 C++11 特性。该项目使用 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(预发行版)
。
有谁可以指点我正确的方向吗?
编辑:这是其中一个文件中的 g++ 的样子:
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
std::mutex
应该在<mutex>
中定义(或者在这里),所以我不认为这是一个 bug - 如果有什么问题,那就是 x86 版本包含了你没有请求的头文件,但我记不清允许到什么程度了。但是加上它不会破坏 x86,对吧?你是否已经为其他的添加了#include <future>
? - Rup<thread>
包含<mutex>
,我认为这在 x86 构建中通过了。我不介意添加所需的包含作为解决方案。 包括<future>
也没有解决其他问题。 它似乎不喜欢template<typename _Res> class __basic_future : public std::__future_base
作为类声明,但没有说明原因。 - sagargp