Linux View executable file dynamic link library related information __linux

Source: Internet
Author: User
Tags imagemagick
LDD < executable file name > View executable link which system dynamic link library
NM < executable file name > see what symbols are in the executable
Strip < executable file name > Remove symbol table can give the executable a thin body
If we want to extract a bit of textual information from an executable program, we can also use the strings command
Strings < executable file name >


The dynamic shared library above the Linux operating system is broadly divided into three categories:

1, the operating system level of shared libraries and the basis of the System tool Library

For example, libc.so, libz.so, libpthread.so, and so on, these system libraries will be placed under the/lib and/usr/lib directories, and in the case of a 64-bit operating system, there will be/lib64 and/usr/lib64 directories. If the operating system has a graphical interface, there will also be a/usr/x11r6/lib directory, if the 64-bit operating system, as well as the/usr/x11r6/lib64 directory. There may also be other specific Linux versions of the system library directory.

The integrity and version of these system library files ensure that the various programs on Linux are functioning correctly.

2. Application-level system shared libraries

Not the operating system itself, but libraries that may be shared by many applications, are typically placed under the/usr/local/lib and/usr/local/lib64 directories. Many of the programs that you compile and install automatically add/usr/local/lib to the GCC-l parameter at compile time and automatically search for shared libraries under/usr/local/lib at run time.

With both types of dynamic shared libraries, apps will automatically find them and don't need your extra setup and worry. This is why. Because these directories are added to the search path of the dynamic Link program by default. The Linux system shared library search path is defined in the/etc/ld.so.conf configuration file. 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

Suppose we compile our own installed ImageMagick graphics library under the/usr/local/imagemagick directory and expect other applications to be able to use ImageMagick's dynamic shared library, so we just need to put/usr/local/ The Imagemagick/lib directory is added to the/etc/ld.so.conf file and then executed: Ldconfig command.

Ldcofig will search all of the above directories and create a cached file/etc/ld.so.cache for the shared library. To confirm that ldconfig has searched the ImageMagick library, we can use the strings command described above to extract textual information from Ld.so.cache to check:

Strings/etc/ld.so.cache | grep ImageMagick


The output results are:

/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
has been successful.

3, the application of the exclusive dynamic shared library

There are many shared libraries that are used only by specific applications, so there is no need to join the system library path to avoid versioning conflicts between shared libraries of the application. So Linux can also temporarily specify an application's shared library search path by setting the environment variable Ld_library_path, as we have shown in the example above, where we can set up Ld_library_path in the application's startup script. Specifies the shared library search path attached to this application so that the application can find it.

Related Article

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.