Asking gcc for the include directory location?

Toralf Lund
Thu Dec 7 10:44:00 GMT 2006

>> Is there any way I can get gcc to tell me where the "normal" include 
>> directory is located?
> No, AFAIK  The 'gcc' is only the "compiler driver" and so doesn't need 
> or handle headers
> at all...
Yeah, but it doesn't handle libraries, either, yet it will tell me where 
those may be located...
>   The clue is in the question: "Which part of GCC needs and handles 
> the headers?"
>> 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?
> There seems to be no "standard" way for this.  Especially for C++ 
> etc.  Anyway when understanding
> that it is the C preprocessor, 'cpp', which needs headers, trying it 
> instead of 'gcc', should give something :
>   arm-coff-cpp -v
For the use I have in mind, I won't know the exact name of the 
preprosessor, though. The idea is to find a general way to determine the 
include directory (or directories) based on a variable containing the 
name of the compiler (driver). The compiler may be assumed to be some 
gcc variant, but nothing is known about the exact version, and it may be 
a native compiler or one of the cross compilers for several different 

I suppose I might extract the name as indicated below, however...
> Like :
> kai@Dell:~> cpp-arm-coff-3.2 -v
> Reading specs from /usr/local/lib/gcc-lib/arm-coff/3.2.3/specs
> Thread model: single
[ ... ]
> After gcc-3.3 the "real C preprocessor" was included in the "real 
> compilers" like 'cc1'
> and 'cc1plus', so running them with some options would tell the 
> headers search paths.
> But how to run them without knowing where they are?   One way is to 
> use the 'gcc'
> option '-print-prog-name=cc1' or '-print-prog-name=cc1plus', for 
> instance :
> kai@Dell:~> `gcc-arm-coff-3.3 -print-prog-name=cc1plus` -v
[ ... ]

So, the information is there, but getting the data and extracting the 
right piece is rather cumbersome. What I thought, really.

To bad ;-/
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/local/include/c++/3.3.4
> /usr/local/include/c++/3.3.4/arm-coff
> /usr/local/include/c++/3.3.4/backward
> /usr/local/include
> /usr/local/lib/gcc-lib/arm-coff/3.3.4/include
> /usr/local/arm-coff/sys-include
> /usr/local/arm-coff/include
> End of search list.
> with "command substitution", asking 'gcc' to tell the full name of 
> 'cc1plus' and then use it
> with the '-v' option...
> Toying with 'cc1', 'cc1plus' etc. using '--help' could reveal other 
> possibilities....  But as was
> seen, there isn't any "standard" for this.  That 'cpp' remains inside 
> 'cc1*' can though be quite
> expected and so using 'cc1*' directly should always work...
> -- 
> For unsubscribe information see

For unsubscribe information see

More information about the crossgcc mailing list