Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen)
Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772012] Sun, 03 September 2017 21:28 Go to next message
Someone Else is currently offline Someone ElseFriend
Messages: 4
Registered: September 2017
Junior Member
Dear all,

Before anybody points me back to existing threads on the topic, I have browsed through anything Google came up with. Nothing works for now.
I have gcc/g++ version 5.4.0 installed on Ubuntu 16.0.4 LTS

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 


running Eclipse Oxygen 4.7.0 Build id: 20170620-1800. I have already added "-ipthread" flag to cross G++ compiler, selected ISO C++11 language in Cross G++ compiler resulting in the compile sequence "-std=c++0x -D__GXX_EXPERIMENTAL_CXX0X__ -O3 -Wall -c -fmessage-length=0 -pthread"

index.php/fa/30586/0/
index.php/fa/30587/0/

I am still having problems with "std::thread" call, with the hint showing "Type 'std::thread' could not be resolved" as shown below

index.php/fa/30588/0/

no matter what I do. Code compiles and executed fine, but the error is annoying ...

Thanks

Marek
  • Attachment: Capture1.PNG
    (Size: 122.16KB, Downloaded 360 times)
  • Attachment: Capture2.PNG
    (Size: 103.81KB, Downloaded 360 times)
  • Attachment: Capture3.PNG
    (Size: 23.83KB, Downloaded 357 times)
Re: Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772137 is a reply to message #1772012] Tue, 05 September 2017 23:53 Go to previous messageGo to next message
David Vavra is currently offline David VavraFriend
Messages: 626
Registered: October 2012
Senior Member
Works for me.
index.php/fa/30614/0/

The tool settings for the Cross G++ Compiler affect only the generated makefile used for the build.
The error you are seeing is generated by the Indexer.
To inform the Indexer, you need to select the builtin provider for the cross compiler(or whatever you are using)
and put -std=c++11 in the provider command.
Such as ${COMMAND} -std=c++11 ${FLAGS} -E -P -v -dD "${INPUTS}"
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc. on the Providers tab
This is unnecessary with newer versions of GCC as they default to c++11 or higher.

[Updated on: Wed, 06 September 2017 00:04]

Report message to a moderator

Re: Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772138 is a reply to message #1772137] Wed, 06 September 2017 00:22 Go to previous messageGo to next message
Someone Else is currently offline Someone ElseFriend
Messages: 4
Registered: September 2017
Junior Member
Thank you for the answer, David

Since I am using the latest and greatest as far as GCC / G++ is concerned (unless I am mistaken, but 5.40, 20160609 build seems to be the latest available in Ubuntu chain), I am not sure what newer versions are there out.

I did have the setting for Cross GCC compiler already, as suggested - here is the screenshot:
index.php/fa/30615/0/
but after several code recompilations, nothing changes and I still have the very same issue.

I noticed though, that when I close Eclipse, restart, problem seems to go away until code is recompiled. Then it is back again :(

Marek

  • Attachment: Capture1.PNG
    (Size: 143.23KB, Downloaded 334 times)

[Updated on: Wed, 06 September 2017 02:26]

Report message to a moderator

Re: Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772228 is a reply to message #1772138] Thu, 07 September 2017 01:19 Go to previous messageGo to next message
David Vavra is currently offline David VavraFriend
Messages: 626
Registered: October 2012
Senior Member
GCC 5.4 may be the latest release for Ubuntu but the current version is 7.2 released mid-August.
https://www.gnu.org/software/gcc/releases.html
I am using 6.3.1 released last December.

Don't know why the problem would come and go.
You might want to select allocate console view under the provider command and see if it is having problems.
You could also try rebuilding the index.

The indexer doesn't handle conditional code using variables that can take on multiple states within a project.
Place the include for <thread> outside of any conditional code that might change between compiles or configurations.
for ecample:
#define THISTIME
//undef THISTIME
#ifdef THISTIME
#include <thread>    // <--- move outside of the conditional code
:
#else
:
#endif

Other than that, I have no further suggestions.
Hope you can track down the cause.


Re: Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772230 is a reply to message #1772228] Thu, 07 September 2017 01:28 Go to previous messageGo to next message
Someone Else is currently offline Someone ElseFriend
Messages: 4
Registered: September 2017
Junior Member
Thank you, David

I tried both of your suggestions and the problem persists, I am afraid.

I will see about updating my G++ version to 6.4.0 or newer ... perhaps that will knock something loose. if not, I am out of ideas at this time :(

Marek
Re: Type 'std::thread' could not be resolved with Eclipse 4.7 (Oxygen) [message #1772232 is a reply to message #1772230] Thu, 07 September 2017 02:33 Go to previous message
Someone Else is currently offline Someone ElseFriend
Messages: 4
Registered: September 2017
Junior Member
I *believe* I found a way around this problem ...

- install gcc/g++ 6.4.0 or newer
- change default calls in Eclipse for gcc / g++ compiler and linker from gcc to gcc-7 (in my case I installed gcc/g++ 7.1.0) and g++ to g++-7
- add explicit path for include directory to where libraries are installed - in my case, it is "/usr/lib/gcc/x86_64-linux-gnu/7" (this last step does not seem to affect the display, though)

Screens with settings are shown below:

index.php/fa/30633/0/
index.php/fa/30634/0/
index.php/fa/30635/0/
index.php/fa/30636/0/

It has been a trip ... but at least right now building & compilation process explicitly calls out version 7 of gcc/g++, as shown below

20:33:26 **** Incremental Build of configuration Release for project twamp-session-responder ****
make all 
Building file: ../src/classStats.cpp
Invoking: Cross G++ Compiler
g++-7 -std=c++1y -D__GXX_EXPERIMENTAL_CXX0X__ -I/usr/lib/gcc/x86_64-linux-gnu/7.1.0 -O3 -Wall -c -fmessage-length=0 -pthread -MMD -MP -MF"src/classStats.d" -MT"src/classStats.o" -o "src/classStats.o" "../src/classStats.cpp"
Finished building: ../src/classStats.cpp
 
Building file: ../src/main.cpp
Invoking: Cross G++ Compiler
g++-7 -std=c++1y -D__GXX_EXPERIMENTAL_CXX0X__ -I/usr/lib/gcc/x86_64-linux-gnu/7.1.0 -O3 -Wall -c -fmessage-length=0 -pthread -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.cpp"
Finished building: ../src/main.cpp
 
Building target: twamp-session-responder
Invoking: Cross G++ Linker
g++-7  -o "twamp-session-responder"  ./src/classStats.o ./src/main.o   -lpthread
Finished building target: twamp-session-responder
 

20:33:30 Build Finished (took 4s.210ms)


Marek

[Updated on: Thu, 07 September 2017 02:35]

Report message to a moderator

Previous Topic:Support for multithread stack in Debug view
Next Topic:Display View in C/C++ IDE
Goto Forum:
  


Current Time: Mon Dec 11 23:01:30 GMT 2017

Powered by FUDForum. Page generated in 0.01638 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software