如何使CDT/Eclipse与C++ 11线程一起使用?

mel*_*lmi 11 c++ multithreading eclipse-cdt c++11

我试图在Eclipse中测试一个C++ 11线程的例子.但是在运行程序时我收到了这条消息:

在抛出'std :: system_error'的实例后调用终止what():不允许操作'

我的系统:ubuntu + gcc 4.7

程序:

#include <iostream>
#include <thread>

void worker()
{
    std::cout << "hello from worker" << std::endl;
}

int main(int argc, char **argv)
{
    std::thread t(worker);
    t.join();
}
Run Code Online (Sandbox Code Playgroud)

......是的,我把-std=c++11-pthread里面C/C++ Build -> Settings -> Tool Settings -> Cross G++ Compiler -> Miscellaneous -> Other Flags.

任何意见?

mel*_*lmi 10

Jonathan Wakely的评论解决了这个问题.

我添加-pthreadC/C++ Build -> Settings -> Tool Settings -> Cross G++ **Linker** -> Miscellaneous -> Other Flags,程序工作正常.

谢谢乔纳森.