Add a dynamic link library in Linux

Source: Internet
Author: User

To sum up, there are three primary methods: 1. Change the/etc/lD. So. conf configuration file, and then refresh

Vim/etc/lD. So. conf
Add/where/you/install/lib
Sudo ldconfig
2. Use ln to link the required so file to the/usr/lib or/lib default directories.

Ln-S/where/you/install/lib/*. So/usr/lib

Sudo ldconfig

 

3. Correct LD_LIBRARY_PATH

Export LD_LIBRARY_PATH =/where/you/install/lib: ¥ LD_LIBRARY_PATH

Sudo ldconfig

First, modify the system file:

In/etc/lD. so. the conf file specifies the default dynamic link library search path, my/etc/lD. so. the conf file contains include/etc/lD. so. conf. d /*. conf

That is to say, it indirectly specifies the file defining the path. We only need to add the required path to/etc/lD. so. conf. run ldconfig in any file in the d directory. However, to make it easy to understand, it is best to find a related file or create a new file, write the path to be added and run ldconfig

The second is to use the variable LD_LIBRARY_PATH:

Add the path to LD_LIBRARY_PATH. Note that if there are more than one path, separate it with a colon. For example, export LD_LIBRARY_PATH =/usr/local/lib/MiniGUI

The third is set during compilation:

When compiling the source code, you can use the parameter-WL and-rpath to specify the path for dynamic search.

I have used only two of the three methods, the first and the second.

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.