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_第1张图片        直接搜索libopencv_objdetect.so.2.4,找到文件准备拷贝 ;文件地址为:

/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张图片

(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张图片

(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

你可能感兴趣的:(ubuntu使用,opencv,人工智能,计算机视觉)