[Solved] error while loading shared libraries: libopencv_highgui.so.3.4: cannot open shared object file…

opencv problem:

./test1: error while loading shared libraries: libopencv_highgui.so.3.4: cannot open shared object file: No such file or directory

This is the problem I have when executing test1this file

error while loading shared libraries: indicates that there is a problem with the shared library.

Two methods are described below.

the first method

Check the dynamic library (shared library) configuration file

sudo gedit /etc/ld.so.conf

Make sure you have the first line of the path
insert image description here
and then update it

sudo ldconfig

The second method

Let’s first look at the shared library of this file that is executed

ldd test1

insert image description here
We can see that there are several libraries that cannot be found

Then we use the locatecommand to locate these libraries

Install the locate command

sudo apt install mlocate

Locate the missing libraries in turn

locate libopencv_highgui.so.3.4

insert image description here
The path is found, then we add the path

Go to the dynamic library configuration folder

cd /etc/ld.so.conf.d

Create a new .conf file, name it whatever you want

You can also add it to the original file without creating a new one.

I create a new opencv.conf file here

sudo vim opencv.conf

It seems that there is no need to add so many paths here

insert image description here

Once the file is saved, it’s time to update the shared library link

sudo ldconfig

After the update, you can delete the newly created .conf file without affecting it.

Read More:

Leave a Reply

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