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?


Dave Korn wrote:
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.
Well I wanted to use gcc or possibly g++ myself, but then someone said that it couldn't be done, and I had to use cpp instead...
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
Anyhow, I must admin that I had overlooked the fact that gcc -v when used in combination with -E, will also include the search path (and not just version/configure info and program names.)

So you're method might work at least in principle. The actual commands presented here don't quite work for me, but I suspect this is due to a minor issue with the grep options or I/O redirections. (I get the full output from gcc -v, not just a directory line.)

Thanks,

- Toralf


-- For unsubscribe information see http://sourceware.org/lists.html#faq


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