简体   繁体   中英

MinGW-w64 Thread Creation Failure

resolution: pass "-static" in miscellanious linker options ---OR--- resolution: Download this MinGW-Version http://sourceforge.net/projects/mingwbuilds/?source=dlp

I am using Eclipse with the MinGW-w64 Toolchain. My GCC version is 4.8

I want to create a application that consists out of 2 Threads. I've allready tried to implement this into my actually application. Thus it didnt work i decided to make a new test app.

Source(main.cpp):

#include <iostream>
#include <thread>

using namespace std;

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

int main() {

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

    return 0;
}   

Build Process:

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)

When running i get the following error:

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

btw: the many -pthread etc. commands come from a couple of trys to make it work. im running win vista 32 bit

I really appreciate if some one knows how to resolve my problem. Thanks in advance!

可以在此处查看可添加到MinGW的任何C ++ 11版本的本机win32 std :: thread实现: https : //github.com/meganz/mingw-std-threads

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM