libopencv_core.so.2.4 cannot open the object file的解决办法
2016-12-20 20:29
1551 查看
当编写好了一个使用到opencv库的程序(程序如下所示,名字为DisplayImage.cpp)后,
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
执行“g++ -Wall DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`”后生成可执行文件DisplayImage,然后运行./DisplayImage 1.jpg时出现错误。
具体见下图:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202004/28/d8521ce8df2965bd1c12af4b29a216a6)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202004/28/15f92cc2ad9ed6eab5d7b0b89d12f37a)
然后在网上搜索之后找到了解决方案:
http://stackoverflow.com/questions/12335848/opencv-program-compile-error-libopencv-core-so-2-4-cannot-open-shared-object-f
按照这个教程,在/etc/ld.so.conf.d目录中创建一个名字为opencv.conf的文件,在里面写入libopencv_core.so.2.4所在的路径(/usr/local/lib),然后运行命令:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
执行“g++ -Wall DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`”后生成可执行文件DisplayImage,然后运行./DisplayImage 1.jpg时出现错误。
具体见下图:
然后在网上搜索之后找到了解决方案:
http://stackoverflow.com/questions/12335848/opencv-program-compile-error-libopencv-core-so-2-4-cannot-open-shared-object-f
按照这个教程,在/etc/ld.so.conf.d目录中创建一个名字为opencv.conf的文件,在里面写入libopencv_core.so.2.4所在的路径(/usr/local/lib),然后运行命令:
sudo ldconfig -v
问题得到完美解决。
运行结果如下:
相关文章推荐
- error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: 的解决办法
- libiconv.so.2: cannot open shared object file解决办法
- PyCharm ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory 解决办法
- while loading shared libraries: libIce.so.33: cannot open shared object file: No such fi"错误的原因和解决办法
- 关于Cannot find or open the PDB file ntdll.dll gdi32.dll user32.dll 的解决办法
- 关于Cannot find or open the PDB file ntdll.dll gdi32.dll user32.dll 的解决办法
- 不能打开文件:mk:@MSITStore:路径[cannot open the file mk@MSITstore:路径]解决办法 转
- cannot open shared object file问题解决办法
- libiconv.so.2: cannot open shared object file解决办法
- openCV program compile error “libopencv_core.so.2.4: cannot open shared object file: No such file or
- svn版本控制的Xcode工程打不开 ,报 the file cannot open错误 的解决办法
- libopencv_shape.so.3.0: cannot open shared object file: No such file or directory 解决笔记
- libreadline.so.6: cannot open shared object file 问题解决办法
- 安装EBS R12时出现libclntsh.so.10.1: cannot open shared object file: No such file or directory的几个解决办法
- VS2010++ 出现 Cannot find or open the PDB file 的错误解决办法
- nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法
- libcaffe.so: cannot open shared object file 解决办法
- rpm: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory解决办法
- linux上运行程序问题,提示cannot open shared object file错误的解决办法
- nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法