2
votes

I am quite desperate. Eclipse keeps on giving the error

'std::thread' could not be resolved

I of course #include <thread>

I tried also the following which I found in another question in stackoverflow: Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery -> CDT GCC Build-in Compiler Settings in the text box entitled Command to get compiler specs append -std=c++11

NOW it looks like: ${COMMAND} ${FLAGS} -E -P -v -dD -std=c++11 "${INPUTS}"

Properties -> C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Dialect

select ISO C++11 from the Language standard drop down.

But it does not work. Anyone can help?

UPDATE: I updated the compiler to version 4.8. The error is still there, but it compiles, and it even works... so it is enough for me! Thanks everyone for your help!

2
you meant "I of course #include <thread>"? - 911
The standard C++ compiler in Ubuntu 12.04 is most likely to old know the option -std=c++11, you can try -std=c++0x. If that doesn't help either, then you need to upgrade to a newer compiler with better C++11 support. - Some programmer dude
I mean with that that I included #include <thread> - Cristina
As stated by Joachim can you post the gcc version? That would help a lot. And possibly all the compiler output. - Rudolfs Bundulis
gcc version: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 - Cristina

2 Answers

1
votes

Note that the std=c++11 flag was only added in gcc 4.7. Try upgrading you compiler or else try the option supported in gcc 4.6, namely: std=c++0x.

0
votes

Had the same problem with eclipse oxygen. Removing support for pthread in the linker and compiler solved it for me.