Reputation: 5759
We need to do some enhancement about a downloaded big package. Assuming the main folder is like
.../proj
and there is
.../proj/Makefile
that will be used to compile the project.
I have added a new folder
.../proj/feature1/file1.h .../proj/feature1/file1.c
file1.c is to include file1.h
so
#include "feature1/file1.h"
Then as the Makefile was executed, it stopped at a command like
gcc -c feature1/file1.c -I. ...
The error message read like it failed to include the file1.h
The same codes CAN be compiled at another instance without triggering errors. Both instances are ubuntu 10.04. I wouldn't say they are identical, but should be very similar. Any idea what went wrong ? Thanks.
James
Upvotes: 0
Views: 127
Reputation: 20262
It depends on the the "-I" parameters to gcc. If the folder "feature1" is in it and not its parent - it will fail. If its parent is in it - it will succeed.
In your case ("-I.") its the "feature1" that's in the search path, not its parent.
Besides, as others mentioned, since both files are in the same directory, you don't need the directory name in the "include
" directive.
Upvotes: 2
Reputation: 19093
If the .h and .c files are in the same directory, I would expect the include to be:
#include "file1.h"
Upvotes: 0
Reputation: 13984
file1.c is to include file1.h
In this case both of files are in the same folder, so I think it have to be:
#include "file1.h"
Upvotes: 1