Howto fix: “error while loading shared libraries”

While installing opencv on an older version of debian for work I kept getting an error while loading shared libraries which turned out to be a pretty easy fix, just finding the libraries and adding them to the dynamic linker.

The libraries I was having trouble with below:
./blobtrack: error while loading shared libraries: libcxcore.so.1: cannot open shared object file: No such file or directory

ffmpeg
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

I used the ‘locate’ command to find where the libraries were eg:
locate libcxcore.so.1
This outputted a few locations of where the library was, I decided to use the /usr/local/lib version as both libraries I needed were in there and did the following command to add them to ld.so.conf and reload the dynamic linker:
sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf && ldconfig'

1 comment to Howto fix: “error while loading shared libraries”

  • john

    hello

    thanks for this howto

    I’m using a raspberry pi
    i tried to follow your instruction, but still having the same error: error while loading shared libraries: libopencv_core.so.3.0: cannot open shared object file: No such file or directory

    knowing that i cross-compiled opencv on my host and just copied the libraries and include files into my raspberry’s /usr/local/lib and /usr/include folders

    thanks in advance

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>