opencv(10):error while loading shared libraries: libopencv_xxx: cannot open shared object file

调用opencv自带的可执行文件时,找不到对应的库,报错如下:

./opencv_createsamples: error while loading shared libraries: libopencv_objdetect.so.2.4: cannot open shared object file: No such file or directory

./opencv_createsamples: error while loading shared libraries: libopencv_calib3d.so.2.4: cannot open shared object file: No such file or directory

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

……

报错原因:

可执行文件opencv_createsamples是opencv2.4.13版本的,而我电脑上opencv默认版本为opencv3.2;这里只需要将opencv2.4.13版本的libopencv_objdetect.so.2.4这里库文件放到对应位置即可。

解决办法–以libopencv_objdetect.so.2.4为例进行分析

注:该解决办法对其他版本的opencv也适用,只需要找到可执行文件对应版本的库文件即可

(1)找到libopencv_objdetect.so.2.4文件( 这一步有多种方法

我先前进行了opencv2.4.13源码编译,如下所示(opencv源码编译可以搜”ubuntu安装opencv”相关内容);

opencv(10):error while loading shared libraries: libopencv_xxx: cannot open shared object file
/home/meng/softwares/opencv-2.4.13/release/lib/libopencv_objdetect.so.2.4

opencv(10):error while loading shared libraries: libopencv_xxx: cannot open shared object file

(2)确认libopencv_objdetect.so.2.4需要放置的位置

到计算机目录下(”/”),搜索libopencv_objdetect.so,结果如图:第一个红框–需要将libopencv_objdetect.so.2.4放置的位置,如下代码;第二个红框–安装opencv2.4.13的位置(如果没有安装,不用管);第三个红框,我源码编译opencv2.4.13的位置

/usr/lib/x86_64-linux-gnu

opencv(10):error while loading shared libraries: libopencv_xxx: cannot open shared object file

(3)拷贝libopencv_objdetect.so.2.4到指定位置

sudo cp /home/meng/softwares/opencv-2.4.13/release/lib/libopencv_objdetect.so.2.4  /usr/lib/x86_64-linux-gnu

(4)其他类似解决

sudo cp /home/meng/softwares/opencv-2.4.13/release/lib/libopencv_calib3d.so.2.4 /usr/lib/x86_64-linux-gnu

sudo cp /home/meng/softwares/opencv-2.4.13/release/lib/libopencv_highgui.so.2.4 /usr/lib/x86_64-linux-gnu

sudo cp /home/meng/softwares/opencv-2.4.13/release/lib/libopencv_imgproc.so.2.4 /usr/lib/x86_64-linux-gnu

sudo cp /home/meng/softwares/opencv-2.4.13/release/lib/libopencv_core.so.2.4 /usr/lib/x86_64-linux-gnu

Original: https://blog.csdn.net/BIT_HXZ/article/details/124887369
Author: biter0088
Title: opencv(10):error while loading shared libraries: libopencv_xxx: cannot open shared object file

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/704636/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球