Eclipse C/C++ (CDT) import files into project - header file not found - include path
- Right click on the project and select properties.
- Select C/C++ General -> Path and Symbols.
- Select Includes tab.
- In Languages list, select 'GNU C' or whatever C compiler tool chain you use.
- Press 'Add...' button and add the directory for the include files.
- Close Properties window and rebuild. You should see new path being used as
-I
in build process.
None of what I have found so far helped, among other things adding the include path in the following places did not work for me:
- Project -> Properties -> C/C++General -> Paths and Symbols -> Includes tab -> GCC C
- Project -> Properties -> C/C++General -> Paths and Symbols -> Includes tab -> GCC C++
- Project -> Properties -> C/C++build -> Settings: Tool settings tab -> GCC C++ Compiler -> includes
- Project -> Properties -> C/C++build -> Settings: Tool settings tab -> GCC C Compiler -> includes
However, adding the include path to:
Project -> properties -> C/C++General -> Paths and Symbols -> Includes tab -> Assembly
while checking 'add to all languages' did work.
Strangely enough this last option does all the above - why they do not work on their own is not really clear to me.
This is assuming that you do not use makefile. If you do then you can forget about changes as listed above. Eclipse will find automagically where all needed input is by analyzing compiler logs. I thought this is magic but it works the following way:
- Build All from project menu - even if that succeeded it may leave some of your files marked with 'faults' because of unknown symbols and such so you have to go for step two:
- update the index: from project window you right click and chose "Properties -> Index -> Rebuild. If the project is big you will see progress in lower right corner of eclipse window.
I think above process can be done in different ways and eclipse can do it all by itself too but for large projects I found manual handling as described above less distracting.