0

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.

2 Answers 2

2

-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.

Sign up to request clarification or add additional context in comments.

Comments

0
  • 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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.