Reputation: 13632
This post: What is the default path for OSX system include files when building a C++ application? gives me a command I can run to see what my default g++ include path is:
echo "" | gcc - -xc -v -E
When I run this, among other things, I get my default include path:
#include <...> search starts here:
/Applications/gcc471/lib/gcc/x86_64-apple-darwin12.0.0/4.7.1/include
/usr/local/include
/Applications/gcc471/include
/Applications/gcc471/lib/gcc/x86_64-apple-darwin12.0.0/4.7.1/include-fixed
/usr/include
/System/Library/Frameworks
/Library/Frameworks
However, I have no idea how this path is constructed. How do I change the order of this default path? Note, this is not $PATH (I know how to do export $PATHs in my .profile). Checking /etc/paths led to a help file explaining how $PATH is actually constructed, but I want to know how this different include path (not sure if it has a system name like $INCLUDEPATH) is constructed, and how I can change its order.
Upvotes: 0
Views: 2166
Reputation: 122381
It's kinda builtin to gcc
; see gcc -dumpspecs
. This article shows you how to change all that stuff, however you don't need to change it, you just add to it using the -I
command line option:
e.g.:
$ gcc -I /path/to/my/fave/lib -c file.cpp
(you can use multiple -I
flags on the same command line).
Upvotes: 1