使用pkg-config和opencv时报错
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
方法一,按照错误信息,执行命令
export PKG_CONFIG_PATH=/your/path:$PKG_CONFIG_PATH
再查看一下
echo $PKG_CONFIG_PATH
/your/path指的是,安装路径中含有opencv4.pc或者opencv.pc的文件夹路径
方法二,把opencv4.pc文件添加到,pkg-config的搜索路径中,执行
find / -name pkgconfig
找到如下路径,
/usr/share/pkgconfig
/usr/lib/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig
选择一个即可
然后把.pc文件复制到选择的文件夹中
例如选择/usr/lib/pkgconfig
sudo cp /opt/opencv4.5.5/lib/pkgconfig/opencv4.pc /usr/lib/pkgconfig