Where does gcc look for C and C++ header files?

前端 未结 9 1766
悲&欢浪女
悲&欢浪女 2020-11-28 17:26

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

9条回答
  •  时光取名叫无心
    2020-11-28 17:55

    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.)

提交回复
热议问题