Home > front end >  How to fix warning "Found OpenCV Windows Pack but it has no binaries compatible with your confi
How to fix warning "Found OpenCV Windows Pack but it has no binaries compatible with your confi

Time:02-02

I am trying to use OpenCV in VS Code. Here's what I've done:

Installed OpenCV for windows.

Added "C:\opencv\build\x64\vc15\bin","C:\opencv\build\x64\vc15\lib" PATH environment variable.

Here's my CMakeLists.txt file.

cmake_minimum_required(VERSION 3.0.0)
project(opencvtest VERSION 0.1.0)

include(CTest)
enable_testing()

find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable(opencvtest main.cpp)

target_link_libraries( opencvtest ${OpenCV_LIBS} )

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

But the file throws the following error:

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\TDM-GCC-64\bin\x86_64-w64-mingw32-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\TDM-GCC-64\bin\x86_64-w64-mingw32-g  .exe -Hc:/Users/Administrator/Desktop/open -Bc:/Users/Administrator/Desktop/open/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- OpenCV ARCH: x64
[cmake] -- OpenCV RUNTIME: mingw
[cmake] -- OpenCV STATIC: OFF
[cmake] CMake Warning at C:/opencv/build/OpenCVConfig.cmake:190 (message):
[cmake]   Found OpenCV Windows Pack but it has no binaries compatible with your
[cmake]   configuration.
[cmake] 
[cmake]   You should manually point CMake variable OpenCV_DIR to your build of OpenCV
[cmake]   library.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:7 (find_package)
[cmake] 
[cmake] 
[cmake] CMake Error at CMakeLists.txt:7 (find_package):
[cmake]   Found package configuration file:
[cmake] 
[cmake]     C:/opencv/build/OpenCVConfig.cmake
[cmake] 
[cmake]   but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
[cmake]   NOT FOUND.
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!

I am trying to run a C file in VS Code that includes <opencv2/opencv.hpp>.

CodePudding user response:

As the error suggests, CMake found your OpenCV installation, but it is not compatible. What is it not compatible with? Your compiler. The OpenCV installation is built with MSVC 15 (it also includes a 14 build). You have asked CMake to use MinGW as your compiler. Libraries need to have been built with the same (well, with some leeway) compiler for everything to work.

You have two options:

  • Build OpenCV yourself with MinGW, or try a third-party MinGW binary distribution of OpenCV. Web searches for "opencv mingw" turn up some possibilities.
  • Use the MSVC compiler for your project. Microsoft offers some free versions of its tools. Just be sure to install the optional older toolsets so that you have access to the VC 15 tools to match OpenCV.
  •  Tags:  
  • Related