Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Resolving CMake Build Errors When Integrating OpenCV with Qt Projects

Tech 1

Environment Configuration

Before proceeding, ensure the following environment variables are properly configured:

  • E:\cmake\bin
  • E:\OpenCV\opencv\build\x64\vc15\bin
  • F:\Qt\Tools\mingw730_64\bin
  • F:\Qt\5.12.4\mingw73_64\bin

Issue 1: Missing Build Program

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". 
CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.

Solution

Navigate to the CMake GUI interface and locate the CMAKE_MAKE_PROGRAM entry. Modify the path to point to mingw32-make.exe in your MinGW installation dierctory. After updating this path, click Configure again to regenerate the build files.

Issue 2: Qt5 Package Not Found

CMake Error at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
  Could not find a package configuration file provided by "Qt5" with any of
  the following names:
    Qt5Config.cmake
    qt5-config.cmake
  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.

Solution

In the CMake GUI, locate the Qt5_DIR or CMAKE_PREFIX_PATH variable. Set its value to the Qt5 configuration directory (typically found at F:\Qt\5.12.4\mingw73_64\lib\cmake\Qt5). Click Configure again to apply the changes.

Issue 3: FFMPEG Dowlnoad Failure

CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
  FFMPEG: Download failed: 6;"Couldn't resolve host name"
  For details please refer to the download log file:
  E:/OpenCv/opencv/opencv_bulid/CMakeDownloadLog.txt

Solution

Open the CMakeDownloadLog.txt file in your build directory. The log indicates missing FFMPEG components:

  • opencv_videoio_ffmpeg.dll
  • opencv_videoio_ffmpeg_64.dll
  • f8e65dbe4a3b4eedc0d2997e07c3f3fd-ffmpeg_version.cmake

Download these files manually from the following URLs:

https://raw.githubusercontent.com/opencv/opencv_3rdparty/6152e132572dfdaa32887eabeb7199bef49b14dc/ffmpeg/opencv_videoio_ffmpeg.dll

https://raw.githubusercontent.com/opencv/opencv_3rdparty/6152e132572dfdaa32887eabeb7199bef49b14dc/ffmpeg/opencv_videoio_ffmpeg_64.dll

https://raw.githubusercontent.com/opencv/opencv_3rdparty/6152e132572dfdaa32887eabeb7199bef49b14dc/ffmpeg/ffmpeg_version.cmake

For the third file, the webpage will redirect to another URL. Save the target content as a text file, then rename it with the .cmake extension. Place all three files in the appropriate 3rdparty directory within your OpenCV source folder, ensuring the filenames match exactly.

Tags: cmakeopencv

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

SBUS Signal Analysis and Communication Implementation Using STM32 with Fus Remote Controller

Overview In a recent project, I utilized the SBUS protocol with the Fus remote controller to control a vehicle's basic operations, including movement, lights, and mode switching. This article is aimed...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.