C++ std::async的交叉编译错误 背景 我在Ubuntu 18.04上使用crosstool ng为我的ARMv7 Raspberry Pi构建了一个工具链。由于一个错误,我对ubsan.c文件做了一些修改 我在Raspberry Pi本身上构建了所需的库,使用将符号链接从绝对更改为相对,压缩/usr和/lib目录以进行传输,并将它们安装在我的工作sysroot目录中 该工具链已被证明适用于许多大型项目 问题

C++ std::async的交叉编译错误 背景 我在Ubuntu 18.04上使用crosstool ng为我的ARMv7 Raspberry Pi构建了一个工具链。由于一个错误,我对ubsan.c文件做了一些修改 我在Raspberry Pi本身上构建了所需的库,使用将符号链接从绝对更改为相对,压缩/usr和/lib目录以进行传输,并将它们安装在我的工作sysroot目录中 该工具链已被证明适用于许多大型项目 问题,c++,arm,cross-compiling,stdasync,C++,Arm,Cross Compiling,Stdasync,我使用这个库构建了一个简单的应用程序。根据库的要求,此应用程序使用C++11标准。当在我的开发机器上编译时,以及在Raspberry Pi上编译时,应用程序会编译并执行。然而,当我使用上述工具链时,我得到了一个与库使用std::async相关的错误 In file included from /home/hicklin/CLionProjects/mqttTest/main.cpp:7:0: /opt/pi/sysroot/usr/local/include/mqtt/client.h: In

我使用这个库构建了一个简单的应用程序。根据库的要求,此应用程序使用C++11标准。当在我的开发机器上编译时,以及在Raspberry Pi上编译时,应用程序会编译并执行。然而,当我使用上述工具链时,我得到了一个与库使用std::async相关的错误

In file included from /home/hicklin/CLionProjects/mqttTest/main.cpp:7:0:
/opt/pi/sysroot/usr/local/include/mqtt/client.h: In member function 'virtual void mqtt::client::connected(const string&)':
/opt/pi/sysroot/usr/local/include/mqtt/client.h:71:76: error: invalid use of incomplete type 'class std::future<void>'
   std::async(std::launch::async, &callback::connected, userCallback_, cause);
                                                                            ^
In file included from /opt/pi/sysroot/usr/local/include/mqtt/client.h:28:0,
                 from /home/hicklin/CLionProjects/mqttTest/main.cpp:7:
/opt/pi/x-tools/arm-unknown-linux-gnueabihf/arm-unknown-linux-gnueabihf/include/c++/6.3.1/future:115:11: note: declaration of 'class std::future<void>'
     class future;
           ^~~~~~
包含在/home/hicklin/CLionProjects/mqttTest/main.cpp:7:0中的文件中:
/opt/pi/sysroot/usr/local/include/mqtt/client.h:在成员函数“virtual void mqtt::client::connected(const string&)”中:
/opt/pi/sysroot/usr/local/include/mqtt/client.h:71:76:错误:无效使用不完整的类型“class std::future”
std::async(std::launch::async,&callback::connected,userCallback,cause);
^
在/opt/pi/sysroot/usr/local/include/mqtt/client.h:28:0中包含的文件中,
from/home/hicklin/CLionProjects/mqttTest/main.cpp:7:
/opt/pi/x-tools/arm unknown linux gnueabihf/arm unknown linux gnueabihf/include/c++/6.3.1/future:115:11:注意:“class std::future”的声明
班级前途;
^~~~~~
尝试修复
  • 我尝试使用-nostdinc标志来阻止编译器使用其标准头,并使用sysroot中的头。错误依然存在
  • 我已经尝试将错误中提到的
    future
    文件替换为Pi中安装的文件(它只有很小的区别)。错误依然存在
  • 我的问题
    是否有人能够指出这个错误的原因和可能需要调查的事情?我是否应该尝试以不同的方式重新构建工具链,或者可能缺少一些标志?

    问题的根源已被确认为是交叉编译器。我的一位老同事给了我他的交叉编译器,他在他的机器上构建了这个编译器,它运行得很好。我将设法抽出时间重新构建交叉编译器,以找出确切的问题所在。我怀疑这可能是由于使用GCC 7.1编译GCC 6.3时出现问题造成的。