+ -
当前位置:首页 → 问答吧 → gcc 搜索不到头文件的问题,为啥?

gcc 搜索不到头文件的问题,为啥?

时间:2010-07-14

来源:互联网

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就可以)

作者: keneth2078   发布时间: 2010-07-14

-I

作者: prolj   发布时间: 2010-07-14

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

作者: 没本   发布时间: 2010-07-14

作者: mirnshi   发布时间: 2010-07-14

回复 没本


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

作者: keneth2078   发布时间: 2010-07-14

VPATH是make用的,GCC不使用这个环境变量。

作者: 没本   发布时间: 2010-07-14

相关阅读 更多