Re: How to determine the standard C/C++ include paths?

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

 



Hi Alex,
On Wed, May 12, 2010 at 12:41:44PM +0100, Alex Flint wrote:
> I was wondering how, on a given system, I can determine which include
> paths are automatically searched by gcc (and similarly for g++ when
> compiling c++ sources). That is, which paths are _not_ searched when
> using -nostdinc (and similarly for -nostdinc++)?
> 
> The reason is that I need to supply these paths to the Eclipse source
> indexer so that it can resolve all my includes and do pretty context
> assist etc.
I don't know of a standard "direct" way to do so (like e.g. "gcc
-print-search-dirs" to show the search paths for binaries/libraries),
but passing "-v" to the preprocessor while compiling an empty file
should work: "gcc -Wp,-v emtpy.c" or "g++ -Wp,-v empty.cc"

gives for me (for C++):

...
#include <...> search starts here:
 /usr/include/c++/4.3
 /usr/include/c++/4.3/x86_64-linux-gnu
 /usr/include/c++/4.3/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.3.2/include
 /usr/lib/gcc/x86_64-linux-gnu/4.3.2/include-fixed
 /usr/include
End of search list.
...

You also can pass "-nostdinc" as additional option - this results in:

...
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.3.2/include
 /usr/lib/gcc/x86_64-linux-gnu/4.3.2/include-fixed
 /usr/include
End of search list.
...

HTH,

Axel


[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