C++ – Eclipse can’t find header file, even though include paths are set

ccygwineclipsefile-not-found

This was an issue we've been dealing with for a while now – we're building a C++ project using the Cygwin toolchain, and no matter what we add in the C++ compiler include paths under project settings, Eclipse can't seem to find the necessary header files.

We have done everything the Stackoverflow community has suggested so far;

  • Made sure include paths were workspace-relative
  • Tried backslashes and forward slashes
  • Tried using Cygwin-specific paths (/cygdrive/c instead of C:/)
  • Checked the compiler output to verify include paths are there
  • Checked the generated makefiles to make sure they're correct
  • Rebuilt the index
  • Deleted the debug folder entirely
  • restarted Eclipse

Basically nothing short of changing the #include <...> code itself to use a full path (C:/.../file.h) worked. This doesn't work for our needs as we need multiple developers to be able to work on this project, and the files themselves are generated dynamically as a result of some of our build procedures.

Best Answer

So here's a fun little detail about Eclipse we didn't know - specific source files themselves can have their own settings.

If you look at your source files and see the following wrench icon, this means that file has some settings which may be contrary to your project-specific settings.

Eclipse wrench key

As a result, our source-specific settings were overriding the include paths, so for those files, none of the headers could be found. The best part is that Eclipse doesn't tell you in any way more explicit than this - the wrench icon does not offer a tool-tip to explain what's going on.

Simply right click on the file > go to Resource Configurations > Reset to Default...

Your header files will be found now, provided that you've written the correct include paths in your project settings.

For reference, we're using Eclipse Kepler - I'm not sure if they fixed this and added more info for users in newer versions.