Linux C include路径问题

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值