I want to cross compile a project from my linux machine to a raspberry pi using Qt creator. Now I have set up a kit with compilers (that I tested to work) and a sysroot. However when I try to compile a simple "Hello world" example in Qt creator I get an error:
#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
I see that Qt tries to use uses the following file for compilation:
/usr/include/c++/5/iostream
However it should use ~/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. 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. 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. This seems to work, but it feels a little dirty. Maybe there are better/cleaner solutions for this?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.