Linux system header file and library file search path
Source: Internet
Author: User
Article Title: Linux system header file and library file search path. Linux is a technology channel of the IT lab in China. Includes some basic classification Include header files such as desktop applications, Linux system management, kernel research, embedded systems and open-source, and so on, linking the database and system definition. In total, the following sources specify gcc to go there.
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
-Lm is required for the options of cos () and other function libraries.
During Compilation:
※Gcc will go to-L
※Find the gcc environment variable LIBRARY_PATH.
※Find the internal directory/lib/usr/local/lib, which was written in the program at the time of compile gcc.
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. Specify the dynamic library search path of the program when compiling the target code (you can also specify the dynamic library search path of the program when compiling the target code.
This is specified through the gcc parameter "-Wl,-rpath," (as shown in Example 3 ). When multiple dynamic library search paths are specified, the paths are separated by colons)
4. Default dynamic library search path/lib
5. Default dynamic library search path/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.
Specifies the path of the dynamic library corresponding to the dynamic library used for the pos output result.
. // The dynamic library search path specified when libpos. so is used to compile the target code
/Root/test/env/lib/libpos. so the dynamic library search path specified by the Environment Variable LD_LIBRARY_PATH
/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
Based on the above results, we can see that the search path sequence of the dynamic library is:
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. The dynamic library search path specified in the configuration file/etc/ld. so. conf;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service