Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

3.1.3 Extended search paths

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.(9)

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. command-line options -I and -L, from left to right
  2. directories specified by environment variables, such as C_INCLUDE_PATH (for C programs), CPLUS_INCLUDE_PATH (for C++ programs) and LIBRARY_PATH
  3. default system directories

In day-to-day usage, directories are usually added to the search paths with the options -I and -L.


 
 
  Published under the terms of the GNU General Public License Design by Interspire