Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse CDT indexer - how to solve unresolved includes

I have a workspace with multiple projects, which all compile with no problems. However, some of the projects are giving a lot of warnings in the editor about unresolved symbols, due to unresolved includes. Most are headers from other projects in the workspace, or third party libraries.

Googling suggests this is a problem with the indexer, but I haven't found any coherent explanations of how to fix it - I assume I need to add the paths to these libraries to the indexer's PATH, but I can't see any option to do that (I am using Juno).

Can anyone please explain to me how to configure CDT's indexer?

I am also getting unresolved include warnings for STL headers in two projects. Some STL headers are resolved but others aren't, and the list doesn't seem to be the same between the two projects (one finds things like vector and iostream, but not sstream or string, the other doesn't find iostream either).

Possibly relevant: these are C++ projects, but all the file extensions are .c. I changed the GCC C Compiler command to 'g++' to compile them, but I guess I also need to do something to the indexer settings to cope with it?

like image 926
jam Avatar asked Aug 30 '12 09:08

jam


2 Answers

Ok, so I've now fixed this issue.

  1. Unresolved includes from other projects in the workspace and third-party libraries was solved by adding the other projects as references. I guess the compiler knew where to look because I'd added the locations to the Includes list, but the indexer didn't (possibly due to eclipse only processing headers once?)

  2. Unresolved includes from STL I fixed by changing all my .c files that were actually C++ to .cpp. Just changing the compile command to 'g++' obviously wasn't enough to tell the indexer to treat the project as C++.

In the case of 1), I needed to clean/rebuild index of the referenced projects first to remove the unresolved include errors.

like image 200
jam Avatar answered Sep 21 '22 16:09

jam


I had a similar problem where my project would build but showed unresolved includes in Eclipse Kepler.

In my case I had taken an existing ARM project and created a custom build configuration that used a different tool chain. The new build configuration had all the correct includes, so the project built correctly but the indexer wasn't picking it up.

I fixed it by setting the indexer to use the active build configuration. In Window->Preferences->C/C++->Indexer, under the section labeled "Build configuration for the indexer" I selected "Use active build configuration" and it cleared it up.

like image 36
Ryan Higgins Avatar answered Sep 21 '22 16:09

Ryan Higgins