Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse C++ include error: no such file or directory

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.

like image 898
Jin Kim Avatar asked Aug 13 '10 17:08

Jin Kim


2 Answers

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.

like image 124
Josh Kelley Avatar answered Oct 21 '22 03:10

Josh Kelley


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

like image 2
Rishiaar Avatar answered Oct 21 '22 02:10

Rishiaar