Home > Software engineering >  How to fix error when using OpenCV in Clion
How to fix error when using OpenCV in Clion

Time:12-23

I'm trying to use OpenCV in Clion and I followed this System variables

And this is my user variable for path:

C:\tools\opencv\build\x64\vc15\bin

I searched this online but there weren't answers for Clion and opencv in c .

Also before I got this error it had another issue but I solved it.

CMake Error at CMakeLists.txt:9 (find_package):
  Found package configuration file:

    C:/tools/opencv/build/OpenCVConfig.cmake

  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
  NOT FOUND.

So I went in the file and changed set(OpenCV_FOUND FALSE) to TRUE. I don't know if this affected anything.

Thanks.

CodePudding user response:

It appears to me that you are building using mingw however your C:\tools\opencv\build\x64\vc15\bin seems to be pointing to libraries built using MSVC. As is seen from the vc15.

You either need to build OpenCV libraries using mingw or you need to use MSVC for your project.

Hope it helps!

EDIT: I did not notice your EDIT... that is definitely a bad idea. OpenCV_FOUND is set by CMake (specifically the FindCMake.cmake or similar config files). DO NOT set this manually yourself.

EDIT2: Here is a link on how to configure CLion so that it uses MSVC

  • Related