首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MinGW-w64线程创建失败

MinGW-w64线程创建失败
EN

Stack Overflow用户
提问于 2013-04-13 19:32:50
回答 1查看 461关注 0票数 2

解析:在混合链接器选项中传递"-static“--或--解析:下载这个MinGW版本的 http://sourceforge.net/projects/mingwbuilds/?source=dlp

我将Eclipse与MinGW-w64工具链结合使用。我的GCC版本是4.8

我想要创建一个由两个线程组成的应用程序。我已经尝试将其实现到我的实际应用程序中。因此,它没有工作,我决定做一个新的测试应用。

Source(main.cpp):

代码语言:javascript
复制
#include <iostream>
#include <thread>

using namespace std;

void test() {
     cout << "works.." << endl;
}

int main() {

    thread t(test);
    t.join();

    return 0;
}   

构建过程:

代码语言:javascript
复制
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)

在运行时,我会得到以下错误:

代码语言:javascript
复制
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位

如果有人知道如何解决我的问题,我真的很感激。提前感谢!

EN

回答 1

Stack Overflow用户

发布于 2014-12-11 11:28:26

有关本机win32 std::线程实现,可添加到MinGW:https://github.com/meganz/mingw-std-threads的任何C++11版本,请参见此处

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15992013

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档