简体   繁体   English

为 raspberry pi 设置 Qt 以进行交叉编译

[英]Setup Qt for cross compile for raspberry pi

I want to cross compile a project from my linux machine to a raspberry pi using Qt creator.我想使用 Qt creator 将一个项目从我的 linux 机器交叉编译到树莓派。 Now I have set up a kit with compilers (that I tested to work) and a sysroot.现在我已经设置了一个带有编译器(我测试过可以工作)和一个 sysroot 的工具包。 However when I try to compile a simple "Hello world" example in Qt creator I get an error:但是,当我尝试在 Qt Creator 中编译一个简单的“Hello world”示例时,出现错误:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hallo!!!" << endl;
    return 0;
}

/usr/include/c++/5/iostream:38: from /usr/include/c++/5/iostream:38, ~/sysroot/usr/include/features.h:364: error: sys/cdefs.h: No such file or directory /usr/include/c++/5/iostream:38: 来自 /usr/include/c++/5/iostream:38, ~/sysroot/usr/include/features.h:364: 错误: sys/cdefs.h: 否这样的文件或目录

I see that Qt tries to use uses the following file for compilation:我看到 Qt 尝试使用以下文件进行编译:

/usr/include/c++/5/iostream /usr/include/c++/5/iostream

However it should use ~/sysroot/usr/include/c++/6/iostream但是它应该使用 ~/sysroot/usr/include/c++/6/iostream

In the kit I use I have specified ~/sysroot as the sysroot, but it seems to use the other c++ includes.在我使用的工具包中,我将 ~/sysroot 指定为 sysroot,但它似乎使用了其他 C++ 包含。 How can I change this?我怎样才能改变这个?

EDIT : I have found a solution for the problem.编辑:我找到了解决问题的方法。 See answers below.请参阅下面的答案。 However I'm not sure if this is the best solution.但是我不确定这是否是最好的解决方案。 I there are better ways, please let me know.我有更好的方法,请告诉我。

I found the problem.我发现了问题。 The default qmake build step adds the argument " -spec linux-g++" to the call to qmake.默认的 qmake 构建步骤将参数“-spec linux-g++”添加到对 qmake 的调用中。 However this causes the wrong compiler to be chosen.然而,这会导致选择错误的编译器。 Since I cannot remove the argument from the qmake build step, I removed the qmake step and added a custom build step which calls qmake and omits the -spec argument.由于我无法从 qmake 构建步骤中删除参数,因此我删除了 qmake 步骤并添加了一个调用 qmake 并省略 -spec 参数的自定义构建步骤。 This seems to work, but it feels a little dirty.这似乎有效,但感觉有点脏。 Maybe there are better/cleaner solutions for this?也许有更好/更清洁的解决方案?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM