cannot open shared object file: No such file or directory

asked 2019-09-05 12:06:06 -0600

Tina  J gravatar image

I was trying to run an OpenCV-based code which was compiled using Cmake and make. I have OpenCV 3.4.7 installed, but I don't know why when running the executable, it picks on the version:

error while loading shared libraries: cannot open shared object file: No such file or directory

I see the followings are already in /usr/local/lib:


How to solve this problem? Why it looks for only 3.1? Where does this number come from?!

edit retag flag offensive close merge delete


I guess the version 3.1 is hardcode in your makefile or Cmake file.

gino0717 gravatar imagegino0717 ( 2019-09-05 21:57:25 -0600 )edit

This should help:

sudo ldconfig -v
supra56 gravatar imagesupra56 ( 2019-09-05 22:05:25 -0600 )edit

It apparently comes from which I built from source. I don't see anything hardcoded. And i did the command... nothing changed on those shared libs.

Tina  J gravatar imageTina J ( 2019-09-05 22:20:44 -0600 )edit

btw, should I run sudo ldconfig -vbefore cmake/make of caffe?

Tina  J gravatar imageTina J ( 2019-09-05 22:53:41 -0600 )edit

Not sure but you may try some following step:

  1. when using the "ldconfig -v" , you may see something like: ->

(not sure what would be in the left. just take an example)

  1. in your sample, you want "", not ""

  2. remove the symbolic link of by

  3. add the symbolic link by

    ln -s /usr/local/lib/
  4. now type the "ldconfig -v " again to check the if the link is what you want.

  5. hope it would not crush your computer. I'm not familiar with this.

gino0717 gravatar imagegino0717 ( 2019-09-06 00:52:08 -0600 )edit

I actually have 3.4.7 installed, but the sample needs 3.1. Isn't it the reverse of what you said? One thing I did was to copy/rename 3.4.7 under the 3.1 name in usr/local/lib. Will it generally work?!

Tina  J gravatar imageTina J ( 2019-09-06 20:53:44 -0600 )edit