Linux shared library. so File naming and dynamic link
In Linux, The. so file is a product of dynamic links. Shared libraries provide a set of functions and provide standard interfaces.Naming rules for shared libraries in Linux
The shared libraries in Linux are not all in this format, such as GLibc's shared library named: libc-x.y.z.so dynamic linker is also part of GLibc, using ld-x.y.z.so named libm (Math Library) and so onSO-NAME MechanismThe format of the shared library to be linked in the system and program is libname. so. x is generally a shared library of the same name with the same primary version number and the highest secondary version number in a carton system. The purpose is to ensure compatibility with the latest version in executable files (ELF files in Linux) when the shared library is upgraded, there are two situations: 1) The main version remains unchanged, it indicates that the shared library is only incrementally upgraded (to ensure that all the original operations are not changed, and a new interface is added on this basis) and does not affect the correctness of the original program running. At this time, the original version does not need to exist. All existing old versions (with a lower version) are replaced with the new shared file library file, run ldconfig [later]. 2) The main version number is changed, at this time, you need to keep the original shared library of the old version (to be compatible with the executable program of the shared library of the previous version), and save the shared library of the new version.Ldconfig in LinuxWhen installing or updating a shared library in the system, you need to update the soft link and dynamic linker to find the file. Therefore, you should run ldconfigldconfig in time to traverse all directories that save the Shared Library/lib/usr /lib, etc, updating soft links based on the actual version of the shared library is easier to use in the form of shared library during GCC compilation, and does not need to spell gcc-o hello such as SO-NAME. c-lNAME can be linked to libNAME using the above form. so. x. y. z (System Version) the dynamic linker loads or searches for shared objects in the following order. 1) the path specified by the Environment Variable LD_LIBRARY_PATH. 2) the path cached file/etc/ld. so. path specified by cache 3) default shared directory first/usr/lib and then/libLD_LIBRARY_PATHIs an environment variable. When LD_LIBRARY_PATH of a program is specified, the dynamic linker first searches for the shared library from the specified path.