Radoslaw Krasimirow
Radoslaw Krasimirow

Reputation: 1873

How to specify default include directory in GCC

I am new in GCC and I am wondering how to tell the compiler that several include directories need to be specified as default for searching .h files. I read that -I dir is the key to accomplish that but doing my makefiles I encounter some problems. For example:

include_dir = C:/Users/rmrd001/Documents/Make/GCC/first/mydir/
FLAGS = -I "$(include_dir)"

func2.o: func2.c func2.h
    gcc $(FLAGS) -c func2.c

And I got the error:

make:*** No rule to make target 'func2.c', needed by 'func2.o'. Stop.

The include_dir is not the working directory. It is working_directory/my_dir. Please help.

Upvotes: 0

Views: 1440

Answers (2)

Laser
Laser

Reputation: 6960

  • You can add path with -I option right in command line;
  • You can specify path with env variable C_INCLUDE_PATH

Also you can find more info on gcc official site and here

Upvotes: 0

Tom Tromey
Tom Tromey

Reputation: 22519

-I is used for finding include files, but not for finding the main file. You have to pass an explicit path to the main file.

Upvotes: 2

Related Questions