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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sergei Organov wrote:
Kai Ruottu <karuottu@xxxxxxxx> writes:

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' !

Sorry, what's the problem with gcc -v ? Consider:

$ echo | gcc -v -x c -E -
In my case the options '-x' and '-E' are belonging to those which I have never needed meanwhile the '-v' and the '-Wa' (give options to the assembler), '-Wl' (give options to the linker) and of course the '-Wp', are those "familiar" ones needed regularly. So one tries to use those one already
knows.

Generally the logic here is the "give a command to 'gcc', 'g++' or 'cpp' (the installed GCC drivers), which puts it to tell those search paths for things". Not "give a command which does a fake 'compile' and for it use some verbose option which puts the fake compile process to tell these things". The '--help', '-print-search-dirs' and the bare '-v' are 'stand-alone' options, one doesn't try to 'compile' anything when using them... With those '-W' options one then tries to give similar 'stand-alone' options to the 'subprograms' somewhere out there, again not trying to compile anything with them, only to
give those standalone options...

The '--help', '--print-search-dirs', '--print-prog-name=' etc. are options which should put GCC to reveal info about itself and there should be an option which will give those headers search paths.

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
/usr/lib/gcc/i486-linux-gnu/4.1.2/cc1 -E -quiet -v - -mtune=i686

All the previous doesn't belong to the "show the headers search paths" in any way, so this output shouldn't be seen with the used command. The 'cpp -v' also outputs these unnecessary things....

ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.1.2/include
 /usr/include
End of search list.

These rows then would be what the command user would like to see...

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"

And these are again something vain....

So my favourite would be the 'cpp -Wp,-v', to use the "real cpp" with the option '-v'.... Surprisingly the 'gcc -Wp,-v' doesn't work - 'gcc' used to exec the "real cpp" and give
that '-v' to it :(

BUT.... Now I and probably others too, learned that '-x' option for selecting the language,
so let's see what it would do if used with "my favourite" command :

[root@Dell gcc]# cpp -x c++ -Wp,-v
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.2/include
/usr/include
End of search list.

Really nice!  Thanks Sergei for teaching us this option!


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux