From: http://blog.csdn.net/rlj021/archive/2008/12/16/3530939.aspx
I. header files Find the required header file during GCC Compilation: ※The search starts with-I. ※Find the GCC environment variable c_include_path, cplus_include_path, objc_include_path. ※Find the specified directory. /Usr/include
/Usr/local/include /Usr/lib/GCC-lib/i386-linux/2.95.2/include /Usr/lib/GCC-lib/i386-linux/2.95.2/http://www.cnblogs.com/http://www.cnblogs.com/include/g++-3 /Usr/lib/GCC-lib/i386-linux/2.95.2/http://www.cnblogs.com/http://www.cnblogs.com/i386-linux/include Library file, but if there is a given prefix when installing GCC, it is /Usr/include
Prefix/include Prefix/xxx-gnulibc/include Prefix/lib/GCC-lib/XXXX-xxx-gnulibc/2.8.1/include Ii. library files During Compilation: ※Gcc will go to-l ※Find the GCC environment variable LIBRARY_PATH. ※Find the default directory/lib:/usr/lib:
/Usr/local/lib: this is written in the original compile gccProgramInternal
Iii. Search Path of dynamic library during runtime
1. Specify the dynamic library search path in the configuration file/etc/lD. So. conf.
2. Specify the dynamic library search path through the Environment Variable LD_LIBRARY_PATH (when multiple dynamic library search paths are specified through this environment variable, the paths are separated by colons) 3. Compile the targetCodeSpecifies the dynamic library search path of the Program (you can also specify the dynamic library search path of the program when compiling the target code. This is through gcc
-Wl,-rpath. When multiple dynamic library search paths are specified, the paths are separated by colons (:). 4. Default dynamic library search path/lib/usr/lib You can find the dynamic library you have searched for by executing the executable file POs and obtain the search sequence of the 1st dynamic databases. Then, you can delete the dynamic library, Then execute the POs program to obtain 2nd dynamic library search paths, and then delete 2nd searched dynamic libraries, In this way, the sequence of Linux dynamic database search is obtained. The correspondence between output results of program POS execution and the searched dynamic library is shown in table 1. Dynamic library used for program POS output results
Specify the corresponding dynamic library search path ././Libpos. So
Dynamic library search path specified when compiling the target code /Root/test/ENV/lib
/Root/test/ENV/lib/libpos. So environment variable LD_LIBRARY_PATH specifies the dynamic library search path /Root/test/CONF/lib
/Root/test/CONF/lib/libpos. So configuration file/etc/lD. So. conf /Lib/libpos. So
Default dynamic library search path/lib /Usr/lib/libpos. So
Default dynamic library search path/usr/lib The search path sequence of a dynamic library is as follows: 1. The dynamic library search path specified when the target code is compiled; 2. The dynamic library search path specified by the Environment Variable LD_LIBRARY_PATH;
3. configuration file/etc/lD. so. the dynamic library search path specified in conf;
4. default dynamic library search path/lib
/usr/lib.