1

I have this source file

//src.c
#include "include/headers/my_header.h"

And gcc fails with this error include/headers/my_header.h: No such file or directory

gcc my_src/src.c -Iinclude/headers

However, it works fine if I rewrite the source file like so:

//src.c
#include "my_header.h"

Now, I'm actually compiling a project I've inherited so I'm not trying to rewrite all of the include statements. What gives?

1 Answer 1

1

The path after -I catenated to whatever is in the #include statement has to match a path in your file system. Try -I., that leads to ./include/headers/my_header.h, and presumably will let GCC find your header.

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

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.