Home > OS >  Using opencv with cmake errors
Using opencv with cmake errors

Time:08-05

So i've been trying to build a github project but it requires opencv, so i installed it according to it's website.

After i tried to build but it gets me this error:

CMake Error at CMakeLists.txt:41 (find_package):
  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.

So I tried to set opencv's location using this:

cmake -DOpenCV_DIR=/c/lib/build_opencv/

But this time it gets me this error:

CMake Error: The source directory "C:/lib" does not appear to contain CMakeLists.txt.

How can i solve it?

I use windows.

CodePudding user response:

You have to execute the install stage from the OpenCV build dir. Either run nmake install or build the INSTALL project from the Visual Studio solution, depending on which generator you chose.

This will copy all needed files to CMAKE_INSTALL_PREFIX, which is C:\Program Files\OpenCV by default. Then use this directory as a value for OpenCV_DIR in your own project.

  • Related