Dump includes paths from g ++

I am trying to write a small assembly script - and want to determine if inclusions are included in the system or not. So I want g ++ to tell me the inclusion path that it uses.

cpp -v seems like the obvious best shot, but it doesn't give me the C ++ path.

So I tried:

g++ -Xpreprocessor -v 

Which doesn't work perfectly right - g ++ commits -v for its own verbose output.

Thanks, Oliver

+44
include build-automation path g ++
Aug 14
source share
1 answer

From Jonathan Wakeli the best option (works on clang too):

 g++ -E -x c++ - -v < /dev/null clang++ -E -x c++ - -v < /dev/null 

I noticed a flag there in cpp to indicate the language. It works like a charm.

 cpp -xc++ -v < /dev/null #include "..." search starts here: #include <...> search starts here: /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0 /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0/x86_64-apple-darwin11.4.0 /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/../../../../include/c++/4.7.0/backward /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/include /usr/local/include /usr/local/Cellar/gcc/4.7.0/gcc/include /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin11.4.0/4.7.0/include-fixed /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. 

Just noticed that this is important for -x c++ to be -xc++ on gcc 4.2

+65
Aug 14
source share



All Articles