On a Unix system, where does gcc look for header files?
I spent a little time this morning looking for some system header files, so I thought this would be good info
To get GCC to print out the complete set of directories where it will look for system headers, invoke it like this:
$ LC_ALL=C gcc -v -E -xc - < /dev/null 2>&1 |
LC_ALL=C sed -ne '/starts here/,/End of/p'
which will produce output of the form
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/5/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
If you have -I
-family options on the command line they will affect what is printed out.
(The sed
command is to get rid of all the other junk this invocation prints, and the LC_ALL=C
is to ensure that the sed
command works -- the "starts here" and "End of search list" phrases are translated IIRC.)