Set the Linux ld_library_path variable __linux

Source: Internet
Author: User

Under Linux, if you write your own dynamic link libraries and need to be called in other programs, you need to have these programs find these dynamic link libraries. If the settings are not correct, 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 placed in the variable Ld_library_path.

At this point, you can use the command export to temporarily test to determine whether this problem:

Export Ld_library_path=/usr/local/lib

Run the above line command in the terminal and run the executable file, which is the problem if it works.

The next question is: The above practice, only temporary set variable ld_library_path , the next boot, all settings will no longer exist; How to keep this value in the Ld_library_path.

We can add the export statement to the ~/.BASHRC or ~/.bash_profile , which reads once every time the shell is logged on and every time it is opened, which is only read once on login. My custom is to add to the ~/.BASHRC , in the end of the file, you can use the following statement to make the setting effective:

Export Ld_library_path= $LD _library_path:/usr/local/lib

After the modification, remember to turn off the current terminal and reopen a new terminal so that the above configuration takes effect.


Reproduced from: http://www.cnblogs.com/waterlin/archive/2011/07/14/2106056.html

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.