免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4099 | 回复: 11
打印 上一主题 下一主题

gcc 搜索不到头文件的问题,为啥? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-07-14 18:07 |只看该作者 |倒序浏览
Feroder11, 要用jrtp的头文件。

已经在/etc/bashrc 设置了 export PATH=$PATH:/usr/include/jrtplib3/
然后用echo PATH也显示设置好了
也重起系统了

但是gcc(或者说是g++)死活找不到/usr/include/jrtplib3/的路径, 为什么?

  (顺便提一下,用VPATH=/usr/inluce/jrtplib3/也不行, 但是用 -I /usr/include/jrtplib3就可以)

论坛徽章:
0
2 [报告]
发表于 2010-07-14 18:11 |只看该作者
-I

论坛徽章:
0
3 [报告]
发表于 2010-07-14 18:17 |只看该作者
GCC不使用PATH环境变量搜索include目录路径,不过用以下这些环境变量都可以。

CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
Each variable's value is a list of directories separated by a special character, much like PATH, in which to look for header files. The special character, PATH_SEPARATOR, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon.
CPATH specifies a list of directories to be searched as if specified with -I, but after any paths given with -I options on the command line. This environment variable is used regardless of which language is being preprocessed.

The remaining environment variables apply only when preprocessing the particular language indicated. Each specifies a list of directories to be searched as if specified with -isystem, but after any paths given with -isystem options on the command line.

In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH is :/special/include, that has the same effect as `-I. -I/special/include'.

来源: http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html

论坛徽章:
2
技术图书徽章
日期:2013-09-04 15:21:51酉鸡
日期:2013-11-01 21:20:20
4 [报告]
发表于 2010-07-14 18:19 |只看该作者

论坛徽章:
0
5 [报告]
发表于 2010-07-14 18:23 |只看该作者
回复 3# 没本


    用VPATH在makefile里面也设置不了吗?

论坛徽章:
0
6 [报告]
发表于 2010-07-14 18:27 |只看该作者
VPATH是make用的,GCC不使用这个环境变量。

论坛徽章:
0
7 [报告]
发表于 2010-07-14 19:32 |只看该作者
回复 6# 没本


    VPATH是make用的,是指找依赖文件的路径吧?

论坛徽章:
0
8 [报告]
发表于 2010-07-14 19:43 |只看该作者
是指在makefile中添加默认搜索路径

论坛徽章:
0
9 [报告]
发表于 2010-07-14 19:47 |只看该作者
回复 8# mgqw


    那为啥找不到我要的头文件? 我都在makefile里面写上  VPATH=/usr/include/jrtplib3

论坛徽章:
2
摩羯座
日期:2013-10-10 14:29:04天蝎座
日期:2014-01-03 09:14:49
10 [报告]
发表于 2010-07-14 19:48 |只看该作者
记不清楚了,VPATH可以指定include路径么?好像只是用来指定目标文件的搜索路径。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP