Current location - Health Preservation Learning Network - Slimming men and women - How to check the version of linux dynamic link library file and other information
How to check the version of linux dynamic link library file and other information
Ldd< executable file name >; See which executables are linked to.

System dynamic link library

Nm < executable file name >;

See what symbols are in the executable file.

Strip & lt executable file name >;

Removing the symbol table can simplify the executable file.

If we want to extract some text information from an executable program, we can also use the strings command.

Use string

< executable file name >;

Dynamic shared libraries on Linux operating system can be roughly divided into three categories:

1, operating system level * * * shared library and basic system tool library.

Such as libc.so, libz.so,

Libpthread.so and so on. , these system libraries will be placed in the /lib and /usr/lib directories. If it is a 64-bit operating system, there will also be /lib64 and /usr.

/lib64 directory. If the operating system has a graphical interface, there will be a directory of /usr/X 1 1R6/lib, and if it is a 64-bit operating system, there will be a directory of/usr/x1R6.

/lib64 directory. There may also be system library directories for other specific Linux versions.

The integrity and correct version of these system library files ensure the normal operation of various programs on Linux.

2, application-level system * * * enjoy the library.

Libraries that are not included in the operating system but can be used by many applications are usually placed in the /usr/local/lib and /usr/local/lib64 directories. Many programs compiled and installed by themselves will automatically add /usr/local/lib to the -L parameter of gcc at compile time, and will automatically go to /usr/local at run time.

/lib find * * * to enjoy the library.

The above two kinds of dynamic * * * libraries will be found automatically by the application, and you don't need to set up or worry about them. Why is this? Because by default, these directories are added to the search path of the dynamic linker. The search path of Linux system * * * library is defined in the configuration file /etc/ld.so.conf, and the content format of this file is roughly as follows:

/usr/X 1 1R6/lib64

/usr/X 1 1R6/lib

/usr/local/lib

/lib64

/library

/usr/lib64

/usr/lib

/usr/local/lib64

/usr/local/ImageMagick/lib

Suppose we compile and install the ImageMagick graphic library in the /usr/local/ImageMagick directory, and hope other applications can use it.

ImageMagick's dynamic * * * library, then we only need to add the /usr/local/ImageMagick/lib directory to the /etc/ld.so.conf file, and then execute: ldconfig.

Give the order.

Ldcofig will search all the above directories and create a cache file /etc/ld.so.cache for the * * * enjoyment library. To confirm that ldconfig has searched ImageMagick's library, we can use the strings command introduced above to extract text information from ld.so.cache for inspection:

Use string

/etc/LD . so . cache | grep ImageMagick

The output result is:

/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++。 therefore

It worked!

3. A dynamic * * * library dedicated to applications

There are many * * * shared libraries that are only used by specific applications, so there is no need to join the system library path to avoid version conflict between * * * shared libraries of applications. Therefore, Linux can also temporarily specify the * * * library search path of the application by setting the environment variable LD_LIBRARY_PATH. Just like the example we gave above, we can set it in advance in the startup script of the application.

LD_LIBRARY_PATH, which specifies the * * * shared library search path attached to this application so that the application can find it.