如何将自己的头文件目录添加到Mac Terminal gcc? [英] How do I add my own header file directory to Mac Terminal gcc?
问题描述
我正在尝试编译包含指定目录中的自定义.h文件的C程序(myProgram.c).如何将目录添加到gcc,以便可以随时使用gcc myProgram
(没有标志,什么都没有)之类的命令随时构建myProgram.c
I'm trying to compile a C program (myProgram.c) that includes a custom .h file that is in a specified directory. How can I add the directory to gcc so that I can build myProgram.c anytime using just a command like gcc myProgram
(with no flags and what not)
推荐答案
您可以通过更改C_INCLUDE_PATH
环境变量来完成此操作,例如
You can do this by altering the C_INCLUDE_PATH
environment variable, e.g.
C_INCLUDE_PATH=~/include
export C_INCLUDE_PATH
您可以将其添加到.bashrc
或.bash_profile
或任何可以始终正确设置环境变量的内容中. 此处提供了有关如何对库和C ++进行相同操作的参考.
You can add that to your .bashrc
or .bash_profile
or whatever to always have the environment variable set properly. Here's a reference on how you can do the same for libraries and C++.
这篇关于如何将自己的头文件目录添加到Mac Terminal gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!