Linux Load Library Directory order __linux

Source: Internet
Author: User


Linux excutable in the implementation of the default is to search the/lib and/usr/lib directories, and then according to the ld.so.conf inside the configuration search absolute path, linux default is not in the current directory search dynamic library. When Windows loads a dynamic library, the default is to load the dynamic libraries in the local directory first, and then search the Windows/system and windows/system32 directories.
The dynamic library search order for Windows, while potentially confusing, is certainly convenient for development and testing, especially when debug and release versions of dynamic libraries often need to be switched for testing. Linux Dynamic Library Search order, although can be said to be more rigorous, but relatively inflexible, and sometimes cause inconvenience.


LDD LB//view process-dependent dynamic libraries in fact, Linux can also support "loading the dynamic library of the current directory." Just set the appropriate environment variable LD_LIBRARY_PATH. There are three ways to set up the method:

1, temporary changes, log out after the failure
Executing in terminal: Export ld_library_path=./

2, let the current account will first load the current directory dynamic library
Modify ~/.bash_profile add two lines to the end of the file: ld_library_path=./and Export Ld_library_path

3, so that all accounts are given priority to load the current directory of the dynamic library
Modify/etc/profile add two lines to the end of the file: ld_library_path=./and Export Ld_library_path

PS: Modifying ld.so.conf does not achieve our goal because ld.so.conf only supports absolute paths.

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.