Ubuntu – how to install opencv4.0 on 18.10

compilingopencvsoftware installation

I have been trying to install opencv4.0.1 on ubuntu for a few weeks now. I have followed the opencv installation instructions
and I am able to make and compile the library, yet after installation, pkgconfig still cant find the library, and when I try to build programs, I get things like missing library errors.

$ pkg-config --cflags 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

Best Answer

According to this issue, OpenCV dropped support for pkg-config. However, this can be added as follows:

Configure

When you run cmake add the additional parameter -D OPENCV_GENERATE_PKGCONFIG=YES e.g.

cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local ..

Then make and sudo make install as before.

Test

Use the name opencv4 instead of just opencv e.g.

pkg-config --cflags opencv4
Related Question