首先安装QT5
然后CMake再Configure后勾选With_QT, Generate后会报错
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. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:679 (include)
解决方法是添加Qt5_DIR的标签, 选择filepath(不能选择path) 后,填入Qt5Config.cmake的文件夹

搜索qt安装路径, 查出Qt5Config.cmake所在文件夹,我的是D:\service\Qt\Qt5.13.0\5.13.0\msvc2017_64\lib\cmake\Qt5

然后虽然是红色,不用管它,按generate

成功


本文解决在CMake中配置Qt5时遇到的错误,详细步骤包括:首先确保安装了QT5,然后在CMake配置过程中勾选With_QT选项。若出现错误提示找不到Qt5配置文件,需在CMake中添加Qt5_DIR标签并指定Qt5Config.cmake的文件路径。通过查找Qt安装目录,定位到Qt5Config.cmake文件,将其路径输入到CMake设置中即可解决问题。
4050

被折叠的 条评论
为什么被折叠?



