Ldconfig and LDD usage

Source: Internet
Author: User

1. ldconfig

Ldconfig is a dynamic link library management command. To share the dynamic link library with the system, you also need to run the dynamic link library management command-ldconfig. Ldconfig
Command is mainly used in the default search directory (/lib and/usr/lib) and dynamic library configuration file/etc/lD. so. find the shared dynamic under the directories listed in Conf
Link Library (format as described earlier, lib *. So *), and then create the connection and cache file required for the Dynamic Loading Program (LD. So). The default cache file is
/Etc/lD. So. cache. This file stores the list of dynamic link library names sorted in order.



In Linux, the shared library mechanism is similar to the high-speed cache mechanism, saving the library information in/etc/lD. So. cache.

When the program is connected, first find the file, and then go to the path of LD. So. conf to find details.

This is why ldconfig needs to be run again after lD. So. conf is modified.

Additionally, ldconfig is in/sbin.



Ldconfig
1. add something to/lib and/usr/lib without modifying/etc/lD. so. conf, but after the execution, you need to call ldconfig. Otherwise, this library will not be found.
2. When you want to add something out of the above two directories, you must modify/etc/lD. So. conf and then call ldconfig. Otherwise, you will not be able to find it.
For example, if you have installed MySQL to/usr/local/MySQL, MySQL has a lot of Libraries under/usr/local/MySQL/lib.
Add a/usr/local/MySQL/lib line under/etc/lD. So. conf and save it to ldconfig.
It is found when the program is running.
3.
If you want to put lib outside these two directories, but do not want to add anything in/etc/lD. So. conf (or you do not have the permission to add something ). That's fine. The export is a global variable.
LD_LIBRARY_PATH, and then find the library in the directory when running the program. Generally, this is only a temporary solution.
.
4. ldconfig is related to running the program and has nothing to do with compiling. During compilation, you should add-L instead of obfuscation.
5. In short, it is recommended that you perform ldconfig for any changes to the library. Otherwise, unexpected results may occur. It won't take too much time, but it will save a lot of time.




Ii. LDD


Purpose: it is used to view the shared libraries required for running the program. It is often used to solve some problems that the program cannot run due to the lack of a library file.
LDD command principle (from network)
1. LDD is not an executable program, but a shell script.
2. LDD can display the dependency of the executable module. The principle is to set a series of environment variables, such as ld_trace_loaded_objects,
Ld_warn, ld_bind_now, ld_library_version, and ld_verbose. When
When the ld_trace_loaded_objects environment variable is not empty, only the dependency of the module is displayed when any executable program is running, and the program is not actually executed. Or you can test it on the shell terminal as follows:
(1) Export ld_trace_loaded_objects = 1
(2) execute any program, such as LS, and check the running result of the program.
3. LDD shows the dependency working principle of the executable module. Its essence is realized by ld-linux.so (loader of ELF dynamic library. We know that LD-
The Linux. So module will work prior to the executable module program and gain control, so when those environment variables above are set, the ld-linux.so selects the display executable
The dependency of the row module.
4, in fact can directly execute the ld-linux.so module, such as:/lib/ld-linux.so.2 -- list Program (which is equivalent to LDD Program)

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.