GCC / G ++在编译期间寻找.h文件的环境变量是什么:LIBRARY_PATH,C_PATH,C_INCLUDE_PATH或CPLUS_PATH? [英] What is the environment variable for GCC/G++ to look for .h files during compilation: LIBRARY_PATH, C_PATH, C_INCLUDE_PATH or CPLUS_PATH?

查看:384
本文介绍了GCC / G ++在编译期间寻找.h文件的环境变量是什么:LIBRARY_PATH,C_PATH,C_INCLUDE_PATH或CPLUS_PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的问题是,有人说LIBRARY_PATH,C_PATH,C_INCLUDE_PATH ,CPLUS_PATH,哪一个是它? http://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html


  CPATH 
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH

每个变量的值是一个由特殊字符分隔的目录列表,很像PATH,用于查找头文件。特殊字符 PATH_SEPARATOR 与目标有关,并在GCC构建时确定。对于基于Microsoft Windows的目标,它是一个分号,几乎所有其他目标都是冒号。



CPATH指定要搜索的目录列表, -I ,但是在命令行中使用 -I 选项给出的任何路径之后。无论使用哪种语言进行预处理,都使用该环境变量。



其余环境变量仅适用于预处理指定的特定语言。每一个都指定了一个要被搜索的目录列表,就像用 -isystem 指定的一样,但是在用 -isystem

在所有这些变量中,一个空的元素指示编译器搜索其当前工作目录。空元素可以出现在路径的开始或结尾。例如,如果 CPATH 的值是:/ special / include ,则与' -I。 -I /专用/包括


我认为大多数设置避免使用环境变量,而是使用 -I 选项。通常会有一个makefile变量或一个IDE设置来控制传递给 -I 的内容。


Is there an environment variable for GCC/G++ to look for .h files during compilation?

I google my question, there are people say LIBRARY_PATH, C_PATH, C_INCLUDE_PATH, CPLUS_PATH, so which one is it?

解决方案

From: http://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html

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'.

I think that most setups avoid using the environment variables and instead pass the include directories in the command line using the -I option. there will usually be a makefile variable or an IDE setting to control what gets passed to -I.

这篇关于GCC / G ++在编译期间寻找.h文件的环境变量是什么:LIBRARY_PATH,C_PATH,C_INCLUDE_PATH或CPLUS_PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆