Asking gcc for the include directory location?

David Querbach querbach@realtime.bc.ca
Fri Dec 8 04:06:00 GMT 2006


On Thu, Dec 07, 2006 at 09:36:52AM +0100, Toralf Lund wrote:

> Is there any way I can get gcc to tell me where the "normal" include 
> directory is located? I mean, for my system's native compiler, this 
> directory is "/usr/include", while on e.g. my arm-coff cross-gcc, it's 
> "/usr/arm-coff/include". Is there any way to ask the compilers to print 
> out these values? If not, how about the full "built-in" include path?
> 
> I've searched the docs for this, but wasn't able to find anything. The 
> "-print-search-dirs" option is of course related to this, but doesn't 
> mention include files, as far as I can tell.

How about this:

  $ echo "" | $(dirname $(gcc -print-prog-name=cc1)/cpp) -v 2>&1 | grep "^ /"
   /usr/local/include
   /usr/lib/gcc/i486-linux-gnu/4.1.2/include
   /usr/include

  $ echo "" | $(dirname $(powerpc-rtems-gcc -print-prog-name=cc1)/cpp) -v 2>&1 | grep "^ /"
   /usr/local/lib/gcc-lib/powerpc-rtems/3.2.3/include
   /usr/local/powerpc-rtems/include

The "$(dirname $(gcc -print-prog-name=cc1)/cpp)" finds the exact cpp
executable which will be called by the named gcc driver.  The "-v" causes
that cpp to dump its configuration and the rest of the line picks out the
include path components.

Regards,

David Querbach
Real-Time Systems Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/crossgcc/attachments/20061208/d234855f/attachment.sig>


More information about the crossgcc mailing list