簡體   English   中英

Qt Creator 2.7.0(Qt 5.0.2)中的C ++ 11線程支持

[英]C++11 thread support in Qt Creator 2.7.0 (Qt 5.0.2)

我正在嘗試使線程在Ubuntu下的Qt Creator中工作。 我設定

QMAKE_CXXFLAGS += -std=c++11 -pthread -lpthread  
CXXFLAGS += -std=c++11 -pthread -lpthread

但它仍然無法正常工作,並且會寫

terminate called after throwing an instance of ‘std::system_error’ 
  what(): Operation not permitted

我嘗試編譯的文件是這個

#include <iostream>
#include <thread>
using namespace std;

void fun(){
}

int main()
{
    thread th(&fun);
    cout << "Hello World!" << endl;
    return 0;
}

我必須將以下行添加到myProject.pro文件中

LIBS += -pthread

所以現在這兩行都可以使用

QMAKE_CXXFLAGS = -std=c++11 
LIBS += -pthread

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM