Reputation: 442
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?
Upvotes: 1
Views: 5161
Reputation: 60444
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.
Upvotes: 1