This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Asking gcc for the include directory location?


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.

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]