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
You can do this by altering the
C_INCLUDE_PATH environment variable, e.g.
C_INCLUDE_PATH=~/include export C_INCLUDE_PATH
You can add that to your
.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++.