Error loading shared library #1463

ghost opened this Issue Nov 21, 2014 · 28 comments


None yet
ghost commented Nov 21, 2014


After sucessfully compile Caffe, I try to test with mnist dataset.
However, when I run the command "./examples/mnist/", I get the following error.

./build/tools/caffe: error while loading shared libraries: cannot open shared object file: No such file or directory

I check my lib "usr/lib/x86_64-linux-gnu" directory, and I just see file. So, there is a different between .8 and .7

Please help me to correct the above error.

Thank you

@ghost ghost changed the title from Error loading shared library to closed Nov 21, 2014
@ghost ghost closed this Nov 21, 2014
@ghost ghost changed the title from closed to Error loading shared library Nov 21, 2014
@ghost ghost reopened this Nov 21, 2014


I'm facing the exact same issue. Does anybody know a solution for this?



Please ask installation questions on the caffe-users mailing list. Thanks!

Check your LD_LIBRARY_PATH and make sure the libhdf5 linked during installation is the same as that in your library path.

@shelhamer shelhamer closed this Nov 27, 2014

I had this same problem. I found that libhdf5-dev created the files


After copying them to the new names


make runtest worked fine. I'm a Linux neophyte though so couldn't tell you why it was looking for the .8 files rather than the .7 files (or why my version of libhdf5-dev installed the .7 files rather than the .8 ones)

SnShine commented Mar 21, 2015

I have ran into the same error while running 'make runtest'. Renaming the files as suggested by @andyljones worked for me. Thank you.


I met the similar problem with the latest caffe but can not find I add the path in anaconda where /anaconda/lib/ It works. But I use matlab interface. After I compiled the caffee_.mexa64 and run the demo. An error occurs: caffe_.mexa64': cannot open shared object file: No such file or directory. It seems there is a library mismatch between matlab and compile. Do you have any idea how to solve that?


I get similar problem cannot open shared object file: No such file or directory

and I find I have the follow so file


Hi, I solved this problem yesterday. It seems c++ compiler and matlab will search /usr/lib/x86_64-linux-gnu to find and If you use anaconda, there will be these version library. Simiple set a soft link to the above path.
I found another guys just change the name of these two to .9. You can have a try

tiangolo commented Jun 4, 2015

I just tried with the Anaconda LD_LIBRARY_PATH but then I had other problems with other libraries. And I think that also affects the Matlab interface, as it is not using the global .so file but the Anaconda's one.

You may try these instructions, they worked for me (but I'm not sure if they would fix the Matlab issue):

  • Go to the libraries directory:

    cd /usr/lib/x86_64-linux-gnu
  • Link the system version of HDF5 from 7 to 9:

    sudo ln -s
    sudo ln -s
  • Update the "Dynamic Linker":

    sudo ldconfig

I wrote a full guide for Ubuntu 14.04 that is pending in the pull request #2129, but you can try it, I just used it (and updated it for the current Caffe code) and it worked:

chwangaa commented Jul 2, 2015

My problem is that there is no file at all in the path. There is however, a /hdf5/serial/ file, and a few and libhdf5_serial files.

Anybody help please?


the same problems, although the can be found in anaconda/lib, it still doesn't work. However, I solved it with @tiangolo 's instructions, thanks


I had the same problem with Caffe which I solved by adding ANACONDA/lib* path to LD_LIBRARY_PATH in ~.bashrc file and it fixed the issue.

export LD_LIBRARY_PATH="/usr/local/cuda/lib64"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib"


Working on Centos7, adding the Anaconda lib to LD_LIBRARY_PATH as suggested by andrusiak has worked for me.


Working on Ubuntu 14.04 using @andrusiak's solution. I just added
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/anaconda/lib" >> ~/.bashrc to my install script after installing Anaconda. Thanks!

jskDr commented Oct 15, 2015

I confirmed that the following is working, while I am considering to add library path suggested @byandrusiak which seems more systematic to me.
~/anaconda/pkgs/hdf5-$ sudo cp /usr/lib/x86_64-linux-gnu/
~/anaconda/pkgs/hdf5-$ sudo cp /usr/lib/x86_64-linux-gnu/
(I try copying like that. Is it okay to solve the problem after I make symbolic links of them? --> Confirmed by myself.)

jskDr commented Oct 15, 2015

So, I contributed this fact to the installation guide for Ubuntu.


@jskDr thanks for the contribution! I tried that, but it resulted in some other errors afterwards as pointed out in this comment above: #1463 (comment) by @guangyu-ryan.

Although right now I don't remember which errors exactly.


Work too, thanks


@andrusiak Thank you. The problem has been fixed according to your advice

biolee commented Dec 30, 2015

LD_LIBRARY_PATH=/usr/local/lib && export LD_LIBRARY_PATH && make runtest
work for me


I think you need to remake your caffe.


I have the same problem. But I didn't find any libhdf5 file in the /usr/lib/x86_64-linux-gnu/, so I just copy it from anaconda, then it is solved.

link9 commented Mar 6, 2016

LD_LIBRARY_PATH=/home/my_user_name/anaconda2/lib && export LD_LIBRARY_PATH && make runtest

worked for me.


do like @link9 or do as follows:
(1) add 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib:/usr/local/hdf5/lib' to the end of file ~/.bashrc
(2) source ~/.bashrc

then run make runtest OK

yihui-he commented May 9, 2016

sudo cp ~/anaconda/lib/libhdf5* /usr/lib/x86_64-linux-gnu/ works for me.


In Ubuntu15.10 with anaconda2, @andrusiak 's instruction works for me. Thanks


If you use conda, the file is in the folder "anaconda/lib". So I used the "LD_LIBRARY_PATH="path to anaconda lib" && export LD_LIBRARY_PATH && make runtest. It works!


the version of is decided by what?
I have in my system, the link is right, but it trys to find .so.9.
Why this will happen, someone can explain that?


My solution : remove anaconda from the path and rebuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment