'How fix "unresolved external symbol" during OpenCV building with "WITH_QT" flag on in Visual Studio 2019?

I want to build an OpenCV library with Qt support from the source with CMake and Visual Studio 2019. Here are steps I did:

  1. Downloaded both opencv-4.5.5 and opencv_contrib-4.5.5 archives from GitHub;
  2. Used CMake to generate the solution file for the Visual Studio. I chose the WITH_QT flag and provided a path for OpenCV extra modules;
  3. Finally, I started building OpenCV in Visual Studio 2019 but faced the this errors.

How can I fix this error and build OpenCV with Qt support? Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source