libopencv_core.so.2.4 cannot open the object file的解决办法

在Ubuntu系统中,一个使用OpenCV库的程序在运行时遇到'libopencv_core.so.2.4 cannot open shared object file'的错误。问题源于系统无法找到库文件。通过在/etc/ld.so.conf.d创建opencv.conf,添加库路径,并运行ldconfig,成功解决了程序的运行问题。
摘要由CSDN通过智能技术生成

当编写好了一个使用到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时出现错误。

具体见下图:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值