After some C / C + + compiles, when it runs, it reports an error saying that the shared library cannot be loaded, for example:
[plain] view plaincopy ./write: error while loading shared libraries: libhdfs.so.0.0.0: cannot open shared object file: No such file or directory
The reason for this error is that the compiled program needs to rely on a shared library during operation. For example, the write executable program needs to rely on a shared library called “libhdfs. So”. (for the difference between dynamic link library and static link library, please refer to relevant Baidu documents)
There are two ways to solve the above problems. Either of the following two ways can be used:
First, add the path of shared library in / etc / Profile:
[plain] view plaincopy export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/server:/home/dcc/libhdfs
As above, two shared libraries under Lujin are added. Note that the spaces between Lujin are separated by colons (“:”).
Second, add the path in / etc / ld.so.conf, and then reload the shared library:
[plain] view plan view code piece on code and derive it to my code piece vi /etc/ld.so.conf
After editing, it is as follows:
[plain] view plan view code piece on code and derive it to my code piece include ld.so.conf.d/*.conf /home/dcc/libhdfs /usr/lib/jvm/java-1.6.0-openjdk-220.127.116.11.x86_64/jre/lib/amd64/server/
In, two paths are added, each of which occupies one line. After editing, reload the Library:
[plain] view plan view code piece on code and derive it to my code piece /sbin/ldconfig -v
As for the difference between the two methods, I speculate that the first one is only loaded when executing C / C + + programs, while the second one should be loaded when starting for the whole system.