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

前端 未结 9 1763
悲&欢浪女
悲&欢浪女 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:58

    You can create a file that attempts to include a bogus system header. If you run gcc in verbose mode on such a source, it will list all the system include locations as it looks for the bogus header.

    $ echo "#include " > t.c; gcc -v t.c; rm t.c
    
    [..]
    
    #include "..." search starts here:
    #include <...> search starts here:
     /usr/local/include
     /usr/lib/gcc/i686-apple-darwin9/4.0.1/include
     /usr/include
     /System/Library/Frameworks (framework directory)
     /Library/Frameworks (framework directory)
    End of search list.
    
    [..]
    
    t.c:1:32: error: bogus.h: No such file or directory
    

提交回复
热议问题