After some C/C ++ compilation, when running, an error is reported that the shared library cannot be loaded, for example, [plain] viewplaincopy./write: errorwhileloadingsharedlibraries: libhdfs. so
After compiling some C/C ++ files, when running, an error is reported 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
This error occurs because a shared library is required during the compilation process. for example, the write executable program depends on a shared library called libhdfs. so. (For details about the differences between dynamic and static link libraries, refer to the Baidu documentation)
There are two ways to solve the problem above. either of the following two methods can be used:
First: Add the path of the shared library to/etc/profile:
[Plain]View plaincopy
- Export LD_LIBRARY_PATH = $ JAVA_HOME/jre/lib/amd64/server:/home/dcc/libhdfs
As shown in the preceding figure, two shared libraries are added. Note that the libraries are separated by colons.
Second: Add the path to/etc/ld. so. conf and reload the shared library:
[Plain]View plaincopy
- Vi/etc/ld. so. conf
After editing:
[Plain]View plaincopy
- 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/
Two paths are added, each of which occupies one row. After editing, reload the database:
[Plain]View plaincopy
- /Sbin/ldconfig-v
As for the differences between the two methods, I guess that the first method is to load only when the C/C ++ program is executed, and the second method should be for the entire system, load at startup.