GCC, How do I show what the default include path is.

Kai Ruottu karuottu@mbnet.fi
Wed Sep 19 11:47:00 GMT 2007


G-Mail wrote:
> I like to know the default include path gcc use. GCC start including 
> files in a defined order of directories
> starting with directories defined during build of gcc. I think there 
> is an command-line option which list
> each include directory but I can't remember the option.
>
> I know gcc -v .....
The preprocessor part, 'cpp',  uses the headers, not  'gcc', so  quite 
logically you should try 'cpp -v' and
not 'gcc -v' !

Ok, this subject was discussed for a while ago, but I can repeat the 
recent situation :

 - there is no 'standard way' to see those header search paths, 
especially with other
   languages than C

- the "real" cpp is nowadays integrated into the 'cc1', 'cc1plus' etc. 
"real" compilers,
   so using the '-v' with them would be one solution. For instance :

      `gcc -print-prog-name=cc1plus` -v

   via "command substitution" on Unix-like shells, the output of the 
command is used
   as the new command and so that '$full_pathname_of_cc1plus -v'  
command is used
   and the C++ and C  headers search paths can be seen....

- only wishes about the 'cpp -print-search-dirs' giving those search 
paths can be given,
   someone should be that kind and implement this and then struggle so 
that this could
   be put into the official GCC sources. Or the 'gcc -print-search-dirs' 
could also give
   the headers search paths, for C...  Then  'g++ -print-search-dirs' 
could show also
   the C++ search paths.

Here are what once worked for C and C++ (giving options to the "real" cpp) :

[root@Dell ~]# cpp-redhat7.3-3.2 -Wp,-v
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc-lib/i386-redhat-linux7.3/3.2.3/include
 /usr/local/i386-redhat-linux7.3/sys-include
 /usr/local/i386-redhat-linux7.3/include
End of search list.

[root@Dell ~]# cpp-redhat7.3-3.2 -Wp,-lang-c++,-v
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/c++/3.2.3
 /usr/local/include/c++/3.2.3/i386-redhat-linux7.3
 /usr/local/include/c++/3.2.3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i386-redhat-linux7.3/3.2.3/include
 /usr/local/i386-redhat-linux7.3/sys-include
 /usr/local/i386-redhat-linux7.3/include
End of search list.

But things will change quite unexpectedly....



More information about the Gcc-help mailing list