m0rtimer m0rtimer - 1 year ago 68
Bash Question

How do I add my own header file directory to Mac Terminal gcc?

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)

Answer Source

You can do this by altering the C_INCLUDE_PATH environment variable, e.g.


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download