I can't make gcc compiler recognize complex paths in "includes".
Here's my toy "main.cpp" file (note the sub-directory in the include statement):
#include "sub/testlib.h"
int main()
{
testlib(6);
return 0;
}
Here's the path to the file "testlib.h" from the folder "main.cpp" lives in: ../lib/sub/testlib.h.
I'm specifying the include directory while compiling:
gcc -c -iquote../lib main.cpp
And the compiler yells at me:
main.cpp:1:10: fatal error: sub/testlib.h: No such file or directory
1 | #include "sub/testlib.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
Of course I can make it compile by removing sub-directory from the path. But this is just an experiment I make after having failed to compile a real-world project. I can't freely change the files there.
How do I force gcc to treat sub-directories well in the includes? Is there a flag or some option that I'm missing here?