Adding custom path to gcc command

1.2k views Asked by At

i know there a a few posts already about this but I do not seem to be able to get it right.

I am working on a shared project using geany and gcc. The file structure looks something like this:

`/Documents/.../project/ main directory of project with makefile`
`/Documents/.../project/src here are some sourcefiles and headers`
`/Documents/.../project/src/extended here are some other source and header files`
`/Documents/.../project/src/tools other header and source files`

now lets say I am working on a sourcefile in /tools that includes from extened with #include"/extended/some_header.h" because my makefile is configured to search for files from /src. However when I am trying to compile the file I am working on right now (by using geany compile option which just calls gcc) I cannot compile it obviously because it cannot find /extended/some_header.h in the /src folder. I have tried adding -iquotes/Documents/.../project/src to the gcc call by geany but it doesn't work either.

1

There are 1 answers

1
Eugene Sh. On BEST ANSWER

The -I flag tells the gcc compiler where it should look for the header files. Passing the -Idir to the compiler is appending the dir path to the head of the search list, effectively making this path higher priority than the previously (or system) defined paths. As for the source path - there is no such an option for gcc itself. Each source file passed to the compiler has to have it's path (absolute or relative). In order to work it around, a Makefile can be provided, defining a list of files to be compiled.