About libraries in Linux

Source: Internet
Author: User
For details about Linux programming and kernel, refer to the following section. Soname
The format is lib. . So. , Which exists in the file system in the form of symbol link. Different Versions reflect interface changes. The actual file name to which it points is usually added after soname. . .

Ldd/ldconfig
A program/shared Library generally depends on some other libraries, which can be viewed using ldd. It lists the soname of the dependent library, because the actual dependency is the library interface, the soname reflects the library interface information. Linux uses ELF as the format of executable programs and libraries. The soname of these dependent libraries is stored in a fileld of ELF. When an executable program is executed, ld. so is responsible for loading the shared library on which it depends to the memory and linking it. it searches for the shared library in the following order:

In the directory specified by the LD_LIBRARY_PATH environment variable
Ld. so. cache file the file corresponding to the shared library
/Usr/lib and/lib directory

Ldconfig creates or updates a soname and writes its correspondence to the cache file ld. so. cache to speed up loading, ld. so will mainly use this ld. so. cache to find the library file. Therefore, after copying the shared library to a directory other than/usr/lib and/lib, run ldconfig to update ld. so. cache to make ld. so can find this shared library. Ldconfig can create and update soname because a field in the ELF File Stores the corresponding soname.

Ld
Ld is the GNU linker and is the last tool used to create an executable program/library.

-Shared
Create a shared library

-L
Ld searches for the archive file to be connected in the directory list. This option adds the specified directory to the front of the default directory list. The default directory list depends on the simulated mode used by ld. The gcc option-print-search-dirs can be used to list the default directories of the current system.

-L
Add a file to the list of archive files to be connected. Ld searches for the libarchive. so file in the directory list of the Search archive. If it does not exist, use the libarchive. a file.

-Rpath-link
When a static executable program (non-shared, non-relocatable, independent of other shared libraries) is created using ld, the shared library entered by ld (directly dependent) it may depend on another shared library. If the indirectly dependent shared library is not included in a static executable program, the result cannot be run independently. This option specifies the path to search for the required shared library. However, ld does not only search for the path specified by this option, the location and sequence of the specific ld search required shared library are described in man.

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.