while loading shared libraries … cannot open shared object file

.build_release/tools/caffe: error while loading shared libraries: libhdf5_hl.so.10: cannot open shared object file: No such file or directory

This means the C loader can not find the file libhdf5_hl.so.10

I found some clues online. Not sure if each solution gives the same lucky bucks. You can get some ideas from them though.

On Linux environment, usually the loader looks for the library file in path:
and other directories when you define for compilation.

As a result, some ideas come out….

Solution 1
Copy the library files to the Linux lib path.

cp /aaa/bbb/ccc/libhdf5_hl.so.10 /usr/lib/

(The actual destination varies.)

Solution 2
Our example shows the loader looks for libhdf5_hl.so.10. Sometimes libhdf5_hl.so.10 is not the real library file. Say the real library file is /xxx/yyy/zzz/libhdf5_hl.so.10.1.0
We can create a symlink to the real file.

ln -s /xxx/yyy/zzz/libhdf5_hl.so.10.1.0 /usr/lib/libhdf5_hl.so.10

Solution 3
If the target file libhdf5_hl.so.10 is located in a special path like /opt/mmm/nnn/, we can set this path in system environment LD_LIBRARY_PATH
Edit ~/.bashrc or ~/.bash_profile

export LD_LIBRARY_PATH=/opt/mmm/nnn:$LD_LIBRARY_PATH

Please don’t forget the “ldconfig” command when you make any change. It triggers the loader to re-scan the lib content.


Leave a Reply

Your email address will not be published. Required fields are marked *