《GCC:the complete referrence》说,gcc的include有以下几个组成:
On a UNIX system, the standard set of system directories is as follows:
/usr/local/include
/usr/lib/gcc-lib/target/version/include
/usr/target/include
/usr/include
通过 gcc -v   *.c 可以看编译时具体过程:
[hyang0@pek-wb-auto ~]$ gcc -v hello.c
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)
/usr/libexec/gcc/i386-redhat-linux/4.1.1/cc1 -quiet -v hello.c -quiet -dumpbase hello.c -mtune=generic -auxbase hello -version -o /tmp/ccPUf6Jg.s
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/http://www.cnblogs.com/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.1/include
/usr/include
End of search list.

GNU C version 4.1.1 20070105 (Red Hat 4.1.1-52) (i386-redhat-linux)
compiled by GNU C version 4.1.1 20070105 (Red Hat 4.1.1-52).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=129176
Compiler executable checksum: 92efef273c2911dfe2bff20f05a618b3
as -V -Qy -o /tmp/ccEed4Cr.o /tmp/ccPUf6Jg.s
GNU assembler version 2.17.50.0.6-2.el5 (i386-redhat-linux) using BFD version 2.17.50.0.6-2.el5 20061020
/usr/libexec/gcc/i386-redhat-linux/4.1.1/collect2 --eh-frame-hdr -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.1/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.1 -L/usr/lib/gcc/i386-redhat-linux/4.1.1 -L/usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/.. /tmp/ccEed4Cr.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.1/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.1/http://www.cnblogs.com/../crtn.o
[hyang0@pek-wb-auto ~]$
可以看到search过程:
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i386-redhat-linux/4.1.1/include
/usr/include
End of search list.
如果要添加查找路径:
The following is a list of the environment variables that can be set to pass instructions
to the preprocessor.
C_INCLUDE_PATH, CPATH, CPLUS_INCLUDE_PATH, DEPENDENCIES_OUTPUT,
OBJC_INCLUDE_PATH, SUNPRO_DEPENDENCIES
对所有用户有效在/etc/profile增加以下内容。只对当前用户有效在Home目录下的
.bashrc或.bash_profile里增加下面的内容:
(注意:等号前面不要加空格,否则可能出现 command not found)
#在PATH中找到可执行文件程序的路径。
export PATH =$PATH:$HOME/bin
#gcc找到头文件的路径
C_INCLUDE_PATH=/usr/include/libxml2:/MyLib
export C_INCLUDE_PATH
#g++找到头文件的路径
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/libxml2:/MyLib
export CPLUS_INCLUDE_PATH
#找到动态链接库的路径
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/MyLib
export LD_LIBRARY_PATH
#找到静态库的路径
LIBRARY_PATH=$LIBRARY_PATH:/MyLib
export LIBRARY_PATH
连接器ld搜索路径和顺序
bash$  ld --verbose | grep SEARCH
SEARCH_DIR("/usr/i486-linux-gnu/lib32"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i486-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
bash$ 

转载于:https://blog.51cto.com/lsjwy/350155

gcc include lib路径扩展相关推荐

  1. gcc怎么设置默认的include,lib路径

    gcc怎么设置默认的include,lib路径 gcc怎么设置默认的include,lib路径 <GCC:the complete referrence>说,gcc的include有以下几 ...

  2. 环境变量,include搜索路径,lib库搜索路径

    环境变量 系统环境变量 我们知道,我们经常要设置一些环境变量,系统环境变量我们非常容易理解.其实我们在windows中经常容易接触.其实环境变量是一个非常广泛的一个概念,它与web应用程序中的web. ...

  3. C和C++中include 搜索路径的一般形式以及gcc搜索头文件的路径

    C和C++中include 搜索路径的一般形式 对于include 搜索的路径: C中可以通过 #include <stdio.h> 和 #include "stidio.h&q ...

  4. 关于环境变量 C++ include搜索路径,lib库搜索路径

    OneCoder在学习C++的过程中,在研究Windows下Eclipse for C/C++开发环境的过程中遇到的一些关于C++环境变量的一些问题.在网上搜索一番,得到下面的文章,与大家分享. 转自 ...

  5. gcc/g++搜索路径

    一:查看gcc/g++默认include路径 `gcc -print-prog-name=cc1plus` -v `g++ -print-prog-name=cc1plus` -v echo 'mai ...

  6. gcc 自动识别的文件扩展名,gcc/g++ -x 选项指定语言,不同 gcc 版本 -std 编译选项支持列表

    对于执行 C 或者 C++ 程序,需要借助 gcc(g++)指令来调用 GCC 编译器. 对于以 .c 为扩展名的文件,GCC 会自动将其视为 C 源代码文件 对于以 .cpp 为扩展名的文件,GCC ...

  7. 添加include文件路径_-isystem以及include_next的副作用

    首先我们先来看下include_next的用法 比如我们想include , 在cmath头文件中你可以看到有类似include_next 的语法,他跟传统的include不同,他不会从你的searc ...

  8. nginx+https+自签名+各种云dns解析+浏览器安全可用include相对路径和绝对路径

    临时解决方案 如何让 Chrome 信任自签名证书:临时方案 不检查证书 chrome://flags/#allow-insecure-localhost 首先要有属于自己的域名在公网上面,可以是阿里 ...

  9. CKFinder 自定义文件路径扩展ConfigurationPathBuilder

    CKFinder 自定义文件路径扩展ConfigurationPathBuilder 打开config.xml当中可以看到如下配置 <basePathBuilderImpl>com.ckf ...

  10. php include的路径问题,php7中include有相对路径无法打开

    目前相对路径,可以用 include"./1.php";) 上一个相对路径,可以用 include"../1.php";) 一开始采用php的include包括 ...

最新文章

  1. 优先队列 堆实现 java
  2. Logisim 一个PLA电路
  3. 纹理对象纹理单元纹理目标_网页设计理论:纹理
  4. SharePoint2010网站备份还原简单介绍
  5. 【大讲堂讲师专访】张甦:数据库选型需因地制宜,MongoDB与MySQL绝非替代
  6. asp.net截取字符串方法
  7. 青岛Uber优步司机奖励政策(9月14日~9月20日)
  8. Java-对象及变量的并发访问小结
  9. innodb逻辑存储结构
  10. 在 Windows 7 下手动删除驱动程序
  11. PLSQL导出表结构和表数据
  12. python xlwt_python的xlwt模块
  13. Alfred神器使用手册
  14. 吴恩达:机器学习的六个核心算法
  15. 从零开始手写VIO 第二章 IMU传感器
  16. 英语不好,可以进外企吗?
  17. SQL Server代理(已禁用代理XP) 出现的原因以及解决方法【通俗易懂,简洁明了】
  18. 诺基亚裁员背水一战:腹背受敌押宝WP手机
  19. iphone自带计算机删除,如何清理iPhone上的垃圾文件
  20. 关于上传文件时,服务器选择列表为空的解决办法

热门文章

  1. PyCharm载入Anaconda环境
  2. 监控摄像头GB28181转RTMP、FLV、HLS、RTSP多种格式实现网页嵌入播放
  3. 开VM虚拟机导致内存和磁盘利用率高
  4. Java通过BCrypt加密
  5. PlaceholderTextView
  6. leangoo更换背景、设置颜色标签功能上线啦!
  7. MySQL5 使用概要
  8. 系统逻辑架构图_如何画好一张架构图?(内含知识图谱)
  9. ORACLE中如何查找定位表最后DML操作的时间小结
  10. Jmeter自定义Java请求,继承AbstractJavaSamplerClient