Search code examples
ceclipsegccheadereclipse-cdt

Eclipse C/C++ (CDT) import files into project - header file not found - include path


I am trying to import files into an Eclipse C project and compile it. The build process cannot find the local header files. The header files are located in the src directory. How can I edit the include path in eclipse? If I were doing it manually I could specify the -I option in gcc.

Building file: ../src/averaging.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/averaging.d" -MT"src/averaging.d" -o"src/averaging.o" "../src/averaging.c"
../src/averaging.c:2:23: fatal error: averaging.h: No such file or directory
compilation terminated.
make: *** [src/averaging.o] Error 1

Solution

    1. Right click on the project and select properties.
    2. Select C/C++ General -> Path and Symbols.
    3. Select Includes tab.
    4. In Languages list, select 'GNU C' or whatever C compiler tool chain you use.
    5. Press 'Add...' button and add the directory for the include files.
    6. Close Properties window and rebuild. You should see new path being used as -I in build process.