Sla*_*zer 2 c++ ubuntu qt multithreading c++11
我试图让线程在Ubuntu下的Qt Creator中运行.我订了
QMAKE_CXXFLAGS += -std=c++11 -pthread -lpthread
CXXFLAGS += -std=c++11 -pthread -lpthread
Run Code Online (Sandbox Code Playgroud)
但它仍然不会工作,会写
terminate called after throwing an instance of ‘std::system_error’
what(): Operation not permitted
Run Code Online (Sandbox Code Playgroud)
我尝试编译的文件就是这个
#include <iostream>
#include <thread>
using namespace std;
void fun(){
}
int main()
{
thread th(&fun);
cout << "Hello World!" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我必须将以下行添加到myProject.pro文件中
LIBS += -pthread
Run Code Online (Sandbox Code Playgroud)
所以它现在与这两行一起工作
QMAKE_CXXFLAGS = -std=c++11
LIBS += -pthread
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2714 次 |
| 最近记录: |