In c/c++ program, if we need include file,there are two ways:
Include <> or
Include “”
When we use include <>
The search order:
1 search “-I” target directory ifwe used in GCC command
2 search the directory defined in“CPLUS_INCLUDE_PATH”(c++) or “C_INCLUDE_PATH”(c) cenvironment variable
3 search GCC built-inpath: /usr/include /usr/local/include /usr/lib/gcc/i686-redhat-linux/<version>/include
When we use include “ ”
1 search current directory, (echo$PWD)
2 search “-I” target directory ifwe used in GCC command
3 search the directory defined in“CPLUS_INCLUDE_PATH”(c++) or “C_INCLUDE_PATH”(c) or “CPATH”(both c and c++)environment variable
4 search GCC built-inpath: /usr/include /usr/local/include /usr/lib/gcc/i686-redhat-linux/<version>/include
to verify, we can use gcc –v test.c toprint the build progress, we can find the result from the output.
Useful link:
http://www.360doc.com/content/13/0524/16/110467_287784511.shtml
http://blog.sina.com.cn/s/blog_6fe0d70d0101ep85.html
tips:
GCC built-in include path prefix(marked byred, means where GCC is installed ) can be found:
Gcc –v
Configured with:../configure --prefix=/usr--mandir=/usr/share/man --infodir=/usr/share/info