一:查看gcc/g++默认include路径

`gcc -print-prog-name=cc1plus` -v
`g++ -print-prog-name=cc1plus` -v echo 'main(){}' | gcc -E -v -

二:include搜索路径

1.当前目录

2.编译的时候指定的路径,比如–prefix=/usr/local,查找的时候去/usr/local/include

3.gcc的specs里,(Command Options),这个不清楚怎么用了。

4.使用-I参数指定的路径,比如g++ demo.cpp -I../include/demo.h ‘这几个路径中-I参数指定的路径优先级最高。 在gcc的手册里是这么说的: omit…

5.gcc环境变量设置

CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH

6.系统标准include路径

'GCC looks in several different places for headers. On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with #include <file> in: /usr/local/include libdir/gcc/target/version/include /usr/target/include /usr/include For C++ programs, it will also look in libdir/../include/c++/version, first. In the above, target is the canonical name of the system GCC was configured to compile code for; often but not always the same as the canonical name of the system it runs on. version is the version of GCC in use.

比如在我的系统上执行
g++ -print-prog-name=cc1plus -v
可以得到系统的标准路径:
“/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../x86_64-redhat-linux/include” 、
#include “…” search starts here: 、
#include <…> search starts here: .
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/x86_64-redhat-linux/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/backward
/usr/local/include
End of search list.
可以看到系统的标准include路径:
/usr/local/include
libdir/gcc/target/version/include
/usr/target/include
/usr/include
libdir/../include/c++/version’

三:动态库的搜索路径搜索的先后顺序是:

1 编译目标代码时指定的动态库搜索路径;

2 环境变量LD_LIBRARY_PATH指定的动态库搜索路径;

3 配置文件/etc/ld.so.conf中指定的动态库搜索路径;

4 默认的动态库搜索路径/lib;

5 默认的动态库搜索路径/usr/lib。

gcc/g++搜索路径相关推荐

  1. Linux下gcc编译中关于头文件与库文件搜索路径相关问题

    如何指定GCC的默认头文件路径 网上偶搜得之,以之为宝:) 原地址:http://blog.chinaunix.net/u/28781/showart.php?id=401631 ========== ...

  2. adb: createprocessw failed: 系统找不到指定的路径_gcc编译过程、gcc命令参数、静态库和动态库搜索路径...

    一.gcc编译过程 gcc -E hello.c -o hello.s //预处理 gcc -S hello.s -o hello.i //编译 gcc -c hello.i -o hello.o / ...

  3. 库文件搜索路径及GCC搜索路径总结

    1. -L指定搜索的路径,   -l指定库名 如何指定GCC的默认头文件路径 网上偶搜得之,以之为宝:) 原地址: http://blog.chinaunix.net/u/28781/showart. ...

  4. gcc指定头文件搜索路径及动态链接库搜索路径

    一.#include <>与#include "" #include <>直接到系统指定的某些目录中去找某些头文件. #include "&quo ...

  5. arm-linux-gcc 头文件搜索路径,gcc和arm-linux-gcc默认头文件库搜索路径

    参考: GCC ARM-linux-GCC 一.GCC gcc编译时查找头文件,按照以下路径顺序查找: 1. gcc编译时,可以设置-I选项以指定头文件的搜索路径,如果指定多个路径,则按照顺序依次查找 ...

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

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

  7. linux下mkdir头文件_整理Linux下gcc编译中关于头文件与库文件搜索路径相关问题

    态库./libpos.so. /root/test/env/lib/libpos.so和/root/test/conf/lib/libpos.so.我们再用源程序 pos_lib.c(见程序5)来创建 ...

  8. Linux系统安装gcc/g++详细过程

    下载: http://ftp.gnu.org/gnu/gcc/gcc-4.5.1/gcc-4.5.1.tar.bz2 浏览: http://ftp.gnu.org/gnu/gcc/gcc-4.5.1/ ...

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

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

最新文章

  1. Ubuntu下eclipse部署mysql jdbc驱动
  2. Spring - Java/J2EE Application Framework 应用框架 第 4 章 属性编辑器,数据绑定,校验与BeanWeapper(Bean封装)
  3. 使用vue-router懒加载解决首次加载时资源过多导致的速度缓慢问题
  4. iOS开发系列文章(持续更新……)
  5. HashSet和LinkedHashSet使用
  6. oracle数据库编码
  7. 还在纠结offer选择吗?也许你该看看这篇文章!
  8. 微信开通检测工具使用小诀窍
  9. PowerBuilder9.0窗口最小化没显示了
  10. QGraphicsView使用详解
  11. 一些实用的电脑小技巧(1)
  12. Excel 数据透视表
  13. laravel api生成接口文档
  14. 免费给你的网站加速,全球访问速度杠杠的
  15. python空间计量经济学_一文读懂空间计量经济学及stata操作
  16. imes (智能生产执行系统) 的整体方案设计
  17. WPF应用程序生成Word文档测试
  18. “智慧工地”为重点工程提速增效
  19. android 9.0谷歌商店,Android 10现可选择Play商店主题模式 附Android 9强制开启深色模式教程...
  20. ffmpeg av_read_frame返回AVERROR_EOF

热门文章

  1. Linux系统vscode断点单步运行调试C++程序
  2. matlab m序列扩频,基于matlab的移位寄存器法m序列的产生
  3. 创业缺乏的不是钱,是智慧
  4. U盘安装ubuntu系统
  5. 正则表达式高级学习技巧
  6. Photoshop滤镜巧制超级美女插画效果(转)
  7. mybatis sql 改写
  8. 共享姨妈巾出来了成为共享家族中的热门产品
  9. 左手内容右手科技,讯飞阅读打造适合年轻人的有声阅读APP
  10. 抗DDOS产品性价比?