我正在尝试为Windows交叉编译一个简单的应用程序:
#include <thread>
void Func(){
return;
}
int main(){
std::thread thr1(Func);
thr1.detach();
return 0;
}
这就是我得到的结果:
$ i686-w64-mingw32-g++ -static-libstdc++ -static-libgcc -pipe -g -std=c++0x ./threadstutor.cpp
./threadstutor.cpp: In function ‘int main()’:
./threadstutor.cpp:8:3: error: ‘thread’ is not a member of ‘std’
./threadstutor.cpp:8:15: error: expected ‘;’ before ‘thr1’
./threadstutor.cpp:9:3: error: ‘thr1’ was not declared in this scope
实际上,如果在Ubuntu上使用g++编译此代码,则没有这样的问题;但是我需要交叉编译Windows版本,而我现在卡住了。
g++ --version
并确保它实际上使用的是正确的版本。除此之外,我不确定为什么您无法使用std::thread
。奇怪。 - Brandon$ ./i686-w64-mingw32-g++ --version
显示i686-w64-mingw32-g++ (GCC) 4.9.0 20131227 (experimental).....
,而且$ ./i686-w64-mingw32-g++ ~/Projects/WinCrossCmplng/StilsoftTest/threadstutor.cpp -static-libstdc++ -static-libgcc -pipe -g -std=c++11
仍然报同样的错误...error: ‘thread’ is not a member of ‘std’...
对于糟糕的格式化表示抱歉。 - Hi-Angel