Linux ldconfig command
I. Introduction
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. The 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 link library under the directory listed in conf (format as described earlier, lib *. so *) to create a dynamic loader (ld. so) the required connection and cache file. the default cached file is/etc/ld. so. cache. This file stores the list of Dynamic Linked Library names in the sorted order.
Ii. Precautions
1. Add content in/lib and/usr/lib. You do not need to modify/etc/ld. so. conf, but you need to execute ldconfig. Otherwise, the library cannot be found.
2. Add content outside the preceding two directories. Modify/etc/ld. so. conf and execute ldconfig. Otherwise, the library will not be found.
For example, if you install mysql to/usr/local/mysql, mysql has a lot of Libraries under/usr/local/mysql/lib. In this case, you need to install mysql in/etc/ld. so. add/usr/local/mysql/lib under conf and run ldconfig.
3. if you want to put lib out of these two directories, you do not want to put it in/etc/ld. so. add content in conf. You can export a global variable LD_LIBRARY_PATH, and then find the library in this directory when running the program. Generally, this is only a temporary solution, which is used when you do not have the permission or need it temporarily.
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 trouble.
This article permanently updates the link address: