我已经按照https://help.ubuntu.com/community/OpenCV的指南安装了OpenCV。
$ sudo su
$ sudo apt-get install build-essential
$ sudo apt-get install libavformat-dev
$ sudo apt-get install ffmpeg
$ sudo apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev
现在当我执行"pkg-config --cflags --libs 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
No package 'opencv' found
我该如何解决这个问题?
-------更新-------
好的,我找到了解决办法...
我创建了一个名为“opencv.pc”的文件并将其复制到“/usr/local/lib/pkgconfig”中,然后我添加了以下两行到“.bashrc”文件中:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
完成啦!现在一切都没问题了。
文件内容如下:
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: opencv
Description: The opencv library
Version: 2.x.x
Cflags: -I${includedir}/opencv -I${includedir}/opencv2
Libs: -L${libdir} -lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy -lopencv_core -lopencv_ml -lopencv_features2d -lopencv_objdetect -lopencv_flann -lopencv_video -lopencv_highgui
更新 - 2014
看起来Ubuntu社区已经完成了有关安装OpenCV的文档,现在您只需要从https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/opencv_latest.sh下载安装脚本并执行即可。
libopencv-dev
后,文件opencv4.pc
已经自动存在于/usr/local/lib/pkgconfig/
目录下。我需要做的唯一一件事情就是复制(或建立符号链接)该文件并将其命名为opencv.pc
。 - fabian/usr/local/lib/pkgconfig
这个目录。 - KansaiRobot