How to add a default include path for GCC in Linux? How to add a default include path for GCC in Linux? linux linux

How to add a default include path for GCC in Linux?


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

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

More details in GCC's documentation.


Create an alias for gcc with your favorite includes.

alias mygcc='gcc -I /whatever/'


just a note: CPLUS_INCLUDE_PATH and C_INCLUDE_PATH are not the equivalent of LD_LIBRARY_PATH.LD_LIBRARY_PATH serves the ld (the dynamic linker at runtime) whereas the equivalent of the former two that serves your C/C++ compiler with the location of libraries is LIBRARY_PATH.