How to add a dynamic link library under CentOS

Source: Internet
Author: User

After some C + + compiled, when run, the error said that the shared library could not be loaded, for example:

./write:error while loading shared libraries:libhdfs.so.0.0.0:cannot open Shared object file:no such file or directory

This error occurs because the compiled program needs to rely on a shared library while it is running, for example, the write executable needs to rely on a shared library called "libhdfs.so". (The difference between the dynamic link library and the static link library, please Baidu related documents)


There are two ways to solve the problem above, and any of the following two kinds can be:


First : Add the path to the shared library in/etc/profile:

Export Ld_library_path= $JAVA _home/jre/lib/amd64/server:/home/dcc/libhdfs

As above, add a two-way shared library, note that the road is separated by a colon (":").

Second : Add the path to the/etc/ld.so.conf and reload the shared library:

Vi/etc/ld.so.conf
Edited as follows:

Include ld.so.conf.d/*.conf
/home/dcc/libhdfs
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/ amd64/server/
On, add two paths, one row for each path, respectively. When you are finished editing, reload the library:

/sbin/ldconfig-v


As for the difference between the two methods, I presume that the first one is loaded only when the C/s + + program is executed, and the second one should be for the entire system, which is loaded at boot time.



Related Article

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.