How does GCC look for includes?
llewelly@dbritsch.dsl.xmission.com
llewelly@dbritsch.dsl.xmission.com
Mon May 8 02:08:00 GMT 2000
On Mon, 8 May 2000, Ivan Martinez wrote:
> llewelly@dbritsch.dsl.xmission.com wrote:
> >
> > On Sun, 7 May 2000, Ivan Martinez wrote:
> >
> > > Hello all. Could you tell me how GCC looks for default include files?.
> > > Does it always look in "/usr/include" or the directories are specified
> > > in any configuration file?. When it looks in a directory, it doesn't
> > > necessarily looks in its subdirectories, does it?. Many thanks.
> > >
> >
> > If you add '-v' to your command line, gcc will display the directories
> > searched for include files, in the order they are searched in.
> >
> > For flags that affect where gcc searches for include files, see
> > http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC11
Sorry, this url should have been:
http://gcc.gnu.org/onlinedocs/gcc_2.html#SEC14
>
> Many thanks for your persistent help. I mean, if I just type "gcc
> myfile.c", without any "-I", does "gcc" look for include files
> anywhere?. In case it does, what tells gcc where to look?. Thanks again.
>
I think it varies somewhat depending on your architecture and
installation. Unfortunately I do not actually know the rules; I just use
-v if I have a question.
On my machine, I get:
{~/cc_exer}gcc -v main.c
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c -v -D__GNUC__=2
-D__GNUC_MINOR__=95 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__
-D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__
-Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
main.c /tmp/ccKuW0DX.i
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/include
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr//lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3
End of omitted list.
[snipped output not relevant to include directories]
The above is probably typical for most unices (the paths containing
'i686-pc-linux-gnu' vary depending on the archetecture), but I seem to
remember that BeOS uses a very different search path, and I would guess
windows and NeXT use unusual search paths as well.
Note that '-v' is only a way of getting some verbose info about what gcc
is doing; it does not change gcc's behavior in any other way.
More information about the Gcc-help
mailing list