M.Elmi M.Elmi - 1 year ago 72
C++ Question

How to make CDT/Eclipse work with C++11 threads?

I tried to test an example of C++11 threads in Eclipse. But I got this message when running the program:

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

My system: 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);

...and yes, I put
C/C++ Build -> Settings -> Tool Settings -> Cross G++ Compiler -> Miscellaneous -> Other Flags

Any comments?

Answer Source

The problem was solved by the comment of Jonathan Wakely.

I added -pthread to C/C++ Build -> Settings -> Tool Settings -> Cross G++ **Linker** -> Miscellaneous -> Other Flags and the program worked correctly.

Thank you Jonathan.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download