Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 739
eat_a_lemon Avatar asked Dec 12 '11 17:12

eat_a_lemon


People also ask

How to include header file path in eclipse?

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.

Do you include C file in header file?

One simple rule, never include C files into other C files, and never include anything into H files. If you are trying to use code written by someone else, then usually there will be a C file and an H file with matching names.

Can you include header files in header files C?

Note: We can't include the same header file twice in any program. Create your own Header File: Instead of writing a large and complex code, we can create your own header files and include them in our program to use it whenever we want.


1 Answers

  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.
like image 107
Kamyar Souri Avatar answered Oct 14 '22 00:10

Kamyar Souri