Search code examples
opencvapt-getpkg-config

Package opencv was not found in the pkg-config search path


I have installed OpenCV using the instructions in https://help.ubuntu.com/community/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

now when i execute "pkg-config --cflags --libs opencv" i get this error:

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

how can I resolve this problem?

-------UPDATE-------

OK, I figured out how to solve the problem...

I made a file named "opencv.pc" and copied it to "/usr/local/lib/pkgconfig" Then i added these two lines to ".bashrc":

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

that's it! everything is OK now.

the contents of the file are:

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

UPDATE - 2014

it seems that the ubuntu community has completed the documentation on installing openCV, all you have to do now is to download the installation script from https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/opencv_latest.sh and execute it.


Solution

  • it seems that the ubuntu community has completed the documentation on installing openCV,

    so all you have to do now is to download the installation script from here and execute it.

    don't forget to make it executable:

    chmod +x opencv_latest.sh
    

    then

    ./opencv_latest.sh