8
votes

I've loaded a C++ project into Eclipse (Europa) and I'm familiarizing myself with the CDT interface.

There is one particularly annoying error message for the following line:

#include "somedir/somefile.h"

somedir/somefile.h: No such file or directory

The include file exists in "/opt/local/project/include/somedir/somefile.h".

Under Project > Properties > C/C++ General > Paths and Symbols > Includes, I've already added the include directory "/opt/local/project/include".

However, this does not seem to solve the issue.

Does anyone know how to deal with this error? Thanks.

Edit: Solved the problem. Turns out that it was a simple issue. I had to "refresh" all the projects in the workspace.

2
This solution worked for me stackoverflow.com/a/14614594/1729501 - user13107

2 Answers

13
votes

Why such an old version? Newer versions of the Eclipse CDT have made vast improvements.

This is a really obvious question, but under Project > Properties > C/C++ General > Paths and Symbols > Includes (at least in the current CDT), there are separate categories for each language (assembly, C, and C++). Did you make sure to add /opt/local/project/include under both C and C++ (if appropriate)?

Alternatively, if your project is built using Make, then simply building your project from within Eclipse will often let Eclipse auto-detect include directories using Make's output, without your having to set the include paths yourself.

If the paths are all set up correctly, then the standard fix for indexing-related problems is to right-click on your project, choose Index, and choose Rebuild.

2
votes

Right Click on project -> Index -> Freshen All Files.