解决方案:在错误的链接器选项中传递“-static” - -要么 - - 解决方案:下载此MinGW版本http://sourceforge.net/projects/mingwbuilds/?source=dlp
我正在使用Eclipse和MinGW-w64工具链。我的GCC版本是4.8
我想创建一个由2个线程组成的应用程序。我已经尝试将其实现到我的实际应用程序中。因此它没有用,我决定制作一个新的测试应用程序。
源(main.cpp中):
#include <iostream>
#include <thread>
using namespace std;
void test() {
cout << "works.." << endl;
}
int main() {
thread t(test);
t.join();
return 0;
}
构建流程:
21:19:51 **** Build of configuration Debug for project Test ****
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=gnu++11 -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
Building target: Test.exe
Invoking: MinGW C++ Linker
g++ -o "Test.exe" ./main.o -lpthread -lwinpthread -pthread -lpthread
Finished building target: Test.exe
21:19:53 Build Finished (took 1s.863ms)
运行时我收到以下错误:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
顺便说一句:许多-pthread等命令来自几个小部件,以使其工作。
我正在运行win vista 32位
如果有人知道如何解决我的问题,我真的很感激。 提前谢谢!
答案 0 :(得分:0)
请参阅此处了解可以添加到MinGW的任何C ++ 11版本的本机win32 std :: thread实现: https://github.com/meganz/mingw-std-threads