QUESTION:
Is there a way to tell the compiler to look the headers files in a specific directory ? I would like to use
#include "my_file.h"
Instead of
#include "/path/to/mylib/include/my_file.h"
(I'm trying to see how I could organize a custom library where headers files would not be in the same folder as the programs).
Sorry for the previous answerers, I had to completely recreate my question as it was not clear.
ANSWER:
Finally I found the answer. I could not add an answer since my post has been marked as duplicate (I believe), but anyway, I could use any of the following:
#include <my_file.h>
#include "my_file.h"
The "trick" was to use the -I option, which adds a header directory.
gcc -I/path/to/mylib/include myprogram.c ~/path/to/mylib/src/file/my_file.c -o myprogram && ./myprogram
In this case, the structure is:
- /path/to/mylib/include/my_file.h
- /path/to/mylib/src/my_file.c
- /path/to/myprogs/myprogram.c
And the current dir was /path/to/myprogs