我正在尝试在CLion中运行这个简单的线程c ++程序
#include <iostream>
#include <thread>
using namespace std;
//Start of the thread t1
void hello() {
cout << "Hello,concurrent world!" << endl; }
int main() {
thread t1(hello); // spawn new thread that calls hello()
cout << "Concurrency has started!" << endl;
t1.join();
cout << "Concurrency completed!";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是有一个未定义的引用pthread的错误,我没有看出我做错了什么...请注意我在CLion上这样做.