Frage

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?

War es hilfreich?

Lösung 2

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.

Andere Tipps

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.

Right click your project in the workspace, choose Properties -> C++ General -> Paths and Symbols, then add includes and symbols for your specific compiler, add libraries, and other stuff you need on the tabs available. After that hit Apply - it should start re-indexing, and your problems should be gone.

All answers are helpful but there was another trick that solved my problem. I found out that in contrast to the compiler the indexer does not process subdirectories of included paths. Therefor you need to be more specific when including header files.

Example
#include "subdirectory\include_2.h"

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top