Search Path for Linux library files

Source: Internet
Author: User
There are many things worth learning about in Linux. Here we mainly introduce the Linux library files. After collecting and sorting out the Linux library file materials, I will share them with you here, I hope you will have a lot to learn.
Linux library files are used when they are connected (static library and Shared Library) and run (only programs that use shared library). Their search paths are set in the system.
In Linux,/lib and/usr/lib
The two directories are used as the default library search path. Therefore, you can directly use these directories without setting the search path. For libraries outside the default library search path, you need to add the location of the database to the library search path.
You can use either of the following methods to set the search path for a Linux library file:
Specify the library search path in the environment variable LD_LIBRARY_PATH.
Add the library search path to the/etc/lD. So. conf file.
It is wise to add the paths that may store library files to/etc/lD. So. conf.
The addition method is extremely simple. It is okay to directly write the absolute path of the Linux library file, one line at a time.
For example:
/Usr/x11r6/lib
/Usr/local/lib
/Opt/lib
Note that the second search path setting method is sufficient for locating the Library (including the shared library and static library) when the program is connected, however, the execution of programs that use the shared library is not
Enough. This is because in order to speed up the positioning of the shared library during program execution and avoid the inefficiency of searching for the shared library using the search path, it is to directly read the library list file
/Etc/lD. So. cache. /
ETC/lD. So. cache is a non-text data file and cannot be edited directly. It is based on
The search path set in/etc/lD. So. conf is/sbin/ldconfig
Command to combine the shared library files in these search paths.
Permission execution ). Therefore, in order to ensure the library location during program execution
After setting the library search path, you must also run the/sbin/ldconfig command to update
/Etc/lD. So. cache file.
Ldconfig
In short, it is used to cache the Linux library files in the paths listed in/etc/lD. So. conf to/etc/lD. So. cache.
For use. Therefore, after installing some library files (for example, just installed Glib), or modifying lD. So. conf to add a new library path, run
/Sbin/ldconfig caches all library files to lD. So. cache. If it is not done, it will not be used even if the library files are clearly under/usr/lib.
In the compilation process, the result is wrong. If the xxx library is missing, you can check it and find that it is clearly there.
In addition to the preceding settings
-L parameters are explicitly specified. Because-L is used
The configured path will be searched first, so the path of the database to be connected is usually specified in this way.
As mentioned above, there are two ways to set the library search path: in the Environment Variable
LD_LIBRARY_PATH and in/etc/lD. So. conf
File. The second setting method requires the root permission to change/etc/lD. So. conf
File and run the/sbin/ldconfig command. In addition, when the system restarts, all
The newly installed GTK + Library will be used when the program is running. Unfortunately, due to GTK +
Version changes, which may cause compatibility issues to applications and cause program running to be abnormal. To avoid the above situations
GTK +
The first method is used to set the search path of the Linux library during installation of the dependent library.
This setting method does not require the root permission and is easy to set:
$ Export LD_LIBRARY_PATH =/opt/GTK/lib: $ LD_LIBRARY_PATH
Run the following command to view the setting content of ld_libray_path:
$ Echo $ LD_LIBRARY_PATH
Now, the two settings of the database are complete.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.