I'm fairly new to C and writing makefiles. I'm trying to compile a C project with the "canonical" structure described here with a makefile. I'm running into a problem where the compilation is failing because it can't find the headers due to using <brackets> instead of "quotes" when including the headers.
How do I tell the compiler where to find the headers in the project?
CodePudding user response:
Usually, you would use the -I
option, followed by a relative or absolute path to the directory where the headers are.
For example:
gcc -c src/foo.c -o obj/foo.o -I src
(However, compiler options are not part of the C standard, so it depends on what compiler you are using, and you did not say.)