Asking gcc for the include directory location?
Dave Korn
dave.korn@artimi.com
Thu Dec 7 13:43:00 GMT 2006
On 07 December 2006 12:36, Mike Frysinger wrote:
> On Thursday 07 December 2006 03:36, 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?
>
> if you run `echo "" | cpp -v` it'll tell you the include search paths ...
> not sure how to get that in an easier format though
> -mike
Sorry, I've been following this thread but I just don't follow :) Why are
we asking the preprocessor about include paths? Only the compiler knows.
After all it's language dependent; the output from "gcc -v" shows the include
paths for C, the output from "g++ -v" shows the include paths for C++. If
your problem is how to find the standard system include dir, this seems to
work for me:
mkdir -p LOOK_HERE_FOR_SYSTEM_DIR &&
gcc -v -E - </dev/null >/dev/null -isystem LOOK_HERE_FOR_SYSTEM_DIR |
grep -A1 LOOK_HERE_FOR_SYSTEM_DIR | tail -1
I couldn't swear for sure it's always going to be the first one in the
system dir include list. It could also be instructive to try and parse out
the --with-prefix setting from the configuration options dumped by "gcc -v"
and compare "$prefix/include" to what the other method gives.
cheers,
DaveK
--
Can't think of a witty .sigline today....
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list