Linux dynamic sharing library and linux dynamic sharing

Source: Internet
Author: User
Tags imagemagick

Linux dynamic sharing library and linux dynamic sharing

The dynamic shared libraries in Linux are roughly divided into three types:
 
I. Operating System-level shared libraries and Basic System Tool Libraries
Libc. so, libz. so, libpthread. so and so on. These system libraries will be placed under the/lib and/usr/lib directories. For a 64-bit operating system, there will also be the/lib64 and/usr/lib64 directories. If the operating system has a graphical interface, the/usr/X11R6/lib directory is available. If the operating system is a 64-bit operating system, the/usr/X11R6/lib64 directory is also available. In addition, there may be other system library directories for specific Linux versions. The complete and correct versions of these system library files Ensure that various programs on Linux can run normally.
 
2. Application-level system shared libraries
Libraries shared by many applications are usually stored in the/usr/local/lib and/usr/local/lib64 directories. Many programs that you compile and install automatically add/usr/local/lib to the gcc-L parameter during compilation, when running, shared libraries are automatically searched under/usr/local/lib. The above two types of dynamic shared libraries will be automatically searched by the application, without additional settings and worries. Why? These directories are added to the search path of the Dynamic Link program by default. The search path of the shared library in Linux is defined in the configuration file/etc/ld. so. conf. The content format of this file is roughly as follows: /usr/X11R6/lib64/usr/X11R6/lib/usr/local/lib/lib64/lib/usr/lib64/usr/lib/usr/local/lib64/usr/local /ImageMagick/lib assume that the ImageMagick graphics library we compile and install is under the/usr/local/ImageMagick directory, if you want other applications to use the dynamic shared library of ImageMagick, you only need to add the/usr/local/ImageMagick/lib directory to the/etc/ld directory. so. in the conf file, run the ldconfig command. Ldcofig searches all the preceding directories and creates a cache file/etc/ld. so. cache for the shared library. To confirm that ldconfig has searched for the ImageMagick library, we can use the strings command described above. so. the cache extracts text information to check: strings/etc/ld. so. cache | grep ImageMagick
/Usr/local/ImageMagick/lib/libWand. so.10
/Usr/local/ImageMagick/lib/libWand. so
/Usr/local/ImageMagick/lib/libMagick. so.10
/Usr/local/ImageMagick/lib/libMagick. so
/Usr/local/ImageMagick/lib/libMagick ++. so.10
/Usr/local/ImageMagick/lib/libMagick ++. so
It is successful!
 
3. Dynamic shared libraries exclusive to applications
Many shared libraries are only used by specific applications, so there is no need to add the path to the system library to avoid version conflicts between shared libraries of applications. Therefore, Linux can also set the environment variable LD_LIBRARY_PATH to temporarily specify the shared library search path for the application, just as in the example above, we can pre-set LD_LIBRARY_PATH in the startup script of the application to specify the shared library search path appended to the application so that the application can find it.

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.