Following the standard Unix convention for search paths, several directories can be specified together in an environment variable as a colon separated list:
DIR1:DIR2:DIR3:...
The directories are then searched in order from left to right. A single dot ‘.’ can be used to specify the current directory.1
For example, the following settings create default include and link paths for packages installed in the current directory . and the include and lib directories under /opt/gdbm-1.8.3 and /net respectively:
$ C_INCLUDE_PATH=.:/opt/gdbm-1.8.3/include:/net/include $ LIBRARY_PATH=.:/opt/gdbm-1.8.3/lib:/net/lib
For C++ programs, use the environment variable CPLUS_INCLUDE_PATH instead of C_INCLUDE_PATH.
To specify multiple search path directories on the command line, the options -I and -L can be repeated. For example, the following command,
$ gcc -I. -I/opt/gdbm-1.8.3/include -I/net/include -L. -L/opt/gdbm-1.8.3/lib -L/net/lib .....
is equivalent to the environment variable settings given above.
When environment variables and command-line options are used together the compiler searches the directories in the following order:
[1] The
current directory can also be specified using an empty path element. For
example, :
DIR1:
DIR2 is equivalent to
.:
DIR1:
DIR2.