pkg-config --modversion opencv (Package opencv was not found in the pkg-config search path.)

Ubuntu20.04安装Opencv20.04
参考

https://blog.csdn.net/qq_45915007/article/details/113000097?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&utm_relevant_index=6

最后尝试环境配置,均失败
验证安装是否完成,执行下面代码:

pkg-config opencv --modversion

报错

Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

参考

https://blog.csdn.net/PecoHe/article/details/97476135

是缺失opencv.pc配置信息文件,故解决方法就是添加这个文件然后将其导入到环境变量中,具体操作如下:

首先创建opencv.pc文件:

prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: opencv
Description: The opencv library
Version:4.5.3
Cflags: -I${includedir}/opencv4
Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann  -lopencv_core
~                                               

Version是Opencv版本(我的是4.5.3)
保存退出,然后将文件导入到环境变量:

export  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

至此opencv.pc就配置好了
再次执行
opencv_version
pkg-config opencv --modversion
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值