views:

13494

answers:

4

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

+19  A: 

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

More details here.

jcrossley3
+1  A: 

Create an alias for gcc with your favorite includes.

alias mygcc='gcc -I /whatever/'

dirkgently
+1  A: 

A gcc spec file can do the job, however all users on the machine will be affected.

See here

dimba
+2  A: 

Here is link to GCC 4.4.3 manual where C_INCLUDE_PATH and CPLUS_INCLUDE_PATH environment variables are documented.

mloskot