Set the Linux LD_LIBRARY_PATH variable

Source: Internet
Author: User

In Linux, if you have written your own dynamic link libraryProgramTo find these dynamic link libraries. If the setting is incorrect, an error similar to the following occurs:

 
Test: Error while loading shared libraries: libexampleso. so.0: cannot open shared object file: no such file or directory

This is because the installation path of the dynamic link library (for example,/usr/local/LIB) is not put in the variable LD_LIBRARY_PATH.

In this case, you can use the commandExportTo test temporarily to confirm whether the problem is:

 
Export LD_LIBRARY_PATH=/Usr/local/lib

Run the preceding command on the terminal and then run the executable file. If the file runs normally, this problem occurs.

The following problem is: the above practice is to set variables temporarily.LD_LIBRARY_PATHAt the next boot, all settings will no longer exist. How can I keep this value in LD_LIBRARY_PATH?

We can~ /. BashrcOr~ /. Bash_profileThe Export Statement is added. The former reads each login and each opening of the shell, and the latter reads only once upon login. My habit is to add~ /. BashrcIn, before the end of the file, you can use the following statement to make the settings take effect:

Export LD_LIBRARY_PATH= $LD_LIBRARY_PATH:/Usr/local/lib

After modification, remember to turn off the current terminal and open a new terminal to make the above configuration take effect.

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.