如何在 Linux 中为 GCC 添加默认包含路径? [英] How to add a default include path for GCC in Linux?

查看:54
本文介绍了如何在 Linux 中为 GCC 添加默认包含路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了通常的包含目录外,我希望 gcc 包含来自 $HOME/include 的文件,但似乎没有类似于 $LD_LIBRARY_PATH.

I'd like gcc to include files from $HOME/include in addition to the usual include directories, but there doesn't seem to be an analogue to $LD_LIBRARY_PATH.

我知道我可以在编译时(或在 makefile 中)在命令行中添加包含目录,但我真的很喜欢这里的通用方法,就像在库案例中一样.

I know I can just add the include directory at command line when compiling (or in the makefile), but I'd really like a universal approach here, as in the library case.

推荐答案

尝试设置 C_INCLUDE_PATH(对于 C 头文件)或 CPLUS_INCLUDE_PATH(对于 C++ 头文件).

Try setting C_INCLUDE_PATH (for C header files) or CPLUS_INCLUDE_PATH (for C++ header files).

正如 Ciro 提到的,CPATH 将为 C 和 C++(以及任何其他语言)设置路径.

As Ciro mentioned, CPATH will set the path for both C and C++ (and any other language).

更多详情请见 GCC 的文档.

这篇关于如何在 Linux 中为 GCC 添加默认包含路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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