解析:在混合链接器选项中传递"-static“--或--解析:下载这个MinGW版本的 http://sourceforge.net/projects/mingwbuilds/?source=dlp
我将Eclipse与MinGW-w64工具链结合使用。我的GCC版本是4.8
我想要创建一个由两个线程组成的应用程序。我已经尝试将其实现到我的实际应用程序中。因此,它没有工作,我决定做一个新的测试应用。
Source(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等命令来自几个尝试,以使其工作。我跑赢32位
如果有人知道如何解决我的问题,我真的很感激。提前感谢!
发布于 2014-12-11 11:28:26
有关本机win32 std::线程实现,可添加到MinGW:https://github.com/meganz/mingw-std-threads的任何C++11版本,请参见此处
https://stackoverflow.com/questions/15992013
复制相似问题