c++ - qt creator opencv windows cmake错误

标签 c++ qt opencv cmake qt-creator

我想配置然后生成 opencv 库供 qt creator 链接它们。 我打开 cmake 3.1.0 并输入源代码和构建路径。

来源:

C:/Users/Philipp_Laptop/Downloads/opencv/sources
build: C:/opencv-mingw

然后我用路径配置了mingw-compiler:

C:/Qt/Tools/mingw482_32/bin/gcc.exe
C:/Qt/Tools/mingw482_32/bin/g++.exe

成功配置后,我设置了 with_Qt 选项。 我配置了两次,它显示了以下错误:


Detected version of GNU GCC: 48 (408)
CMake Warning (dev) at cmake/OpenCVUtils.cmake:261 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "WIN32" will no longer be dereferenced when the
  policy is set to NEW.  Since the policy is not set the OLD behavior will be
  used.
Call Stack (most recent call first):
  CMakeLists.txt:127 (OCV_OPTION)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
  By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any
  of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
  "Qt5Core_DIR" to a directory containing one of the above files.  If
  "Qt5Core" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:447 (include)


CMake Warning at cmake/OpenCVFindLibsGUI.cmake:19 (find_package):
  By not providing "FindQt5Gui.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Gui", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Gui" with any
  of the following names:

    Qt5GuiConfig.cmake
    qt5gui-config.cmake

  Add the installation prefix of "Qt5Gui" to CMAKE_PREFIX_PATH or set
  "Qt5Gui_DIR" to a directory containing one of the above files.  If "Qt5Gui"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:447 (include)


CMake Warning at cmake/OpenCVFindLibsGUI.cmake:20 (find_package):
  By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Qt5Widgets", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5Widgets" with
  any of the following names:

    Qt5WidgetsConfig.cmake
    qt5widgets-config.cmake

  Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
  "Qt5Widgets_DIR" to a directory containing one of the above files.  If
  "Qt5Widgets" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:447 (include)


CMake Warning at cmake/OpenCVFindLibsGUI.cmake:21 (find_package):
  By not providing "FindQt5Test.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Test", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Test" with any
  of the following names:

    Qt5TestConfig.cmake
    qt5test-config.cmake

  Add the installation prefix of "Qt5Test" to CMAKE_PREFIX_PATH or set
  "Qt5Test_DIR" to a directory containing one of the above files.  If
  "Qt5Test" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:447 (include)


CMake Warning at cmake/OpenCVFindLibsGUI.cmake:22 (find_package):
  By not providing "FindQt5Concurrent.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "Qt5Concurrent", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5Concurrent"
  with any of the following names:

    Qt5ConcurrentConfig.cmake
    qt5concurrent-config.cmake

  Add the installation prefix of "Qt5Concurrent" to CMAKE_PREFIX_PATH or set
  "Qt5Concurrent_DIR" to a directory containing one of the above files.  If
  "Qt5Concurrent" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:447 (include)


Looking for Q_WS_X11
Looking for Q_WS_X11 - not found
Looking for Q_WS_WIN
Looking for Q_WS_WIN - found
Looking for Q_WS_QWS
Looking for Q_WS_QWS - not found
Looking for Q_WS_MAC
Looking for Q_WS_MAC - not found
Found OpenGL: opengl32  
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  Could NOT find Qt4 (missing: QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE
  QT_QTTEST_LIBRARY QT_UIC_EXECUTABLE) (found version "4.8.6")
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindQt4.cmake:1331 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/OpenCVFindLibsGUI.cmake:34 (find_package)
  CMakeLists.txt:447 (include)


Configuring incomplete, errors occurred!
See also "C:/opencv-mingw/CMakeFiles/CMakeOutput.log".
See also "C:/opencv-mingw/CMakeFiles/CMakeError.log".

最佳答案

为此,我在 Windows 下使用了 CMake GUI,因此我将引用这种方法。 让我们从与CMAKE_PREFIX_PATH not defined 相关的问题开始。 要解决此问题,您只需在 CMAKE GUI 上按 ADD 并添加名为 CMAKE_PREFIX_PATH 且值为 C 的 PATH 类型变量:/Bin/Qt/5.3/mingw482_32/lib/cmake/ 但使用您自己安装的 Qt5。您现在指向的目录包含您需要的所有模块:Qt5 目录、Qt5AxBase...

此时您按下配置,您应该使 QT_QMAKE_EXECUTABLE 无效。您需要正确设置它,在我的例子中:C:/Bin/Qt/5.3/mingw482_32/bin/qmake.exe

然后再次按配置并查看是否仍然存在一些错误(你有其他错误我从未见过但可能是之前错误的结果),在我的情况下这解决了所有问题并且构建继续进行。

MINGW 配置似乎没问题:我只是将 bin MINGW 路径作为第一个条目放入 PAT 变量并使用 CMAKE 中的默认编译器(但你的解决方案和我的解决方案一样有效。

关于c++ - qt creator opencv windows cmake错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26865635/

相关文章:

C++:GetAsyncKeyState() 不会立即注册按键

c++ - 如何在QT上配置OpenSSL

c++ - 将 "a set strings"和 "input from QLineEdit"连接成一个 QString

Qt ComboBox->addItem() Integer to Qstring 转换错误?

python - MacPorts 安装后,Python 中的 OpenCV 模块失败(退出代码 139)

c++ - 使用 opencv 从帧创建 divx 编码的 avi

c# - 如何检索可执行文件的相对路径

c++ - 如何使用 CMake 为其他项目 'install' 和使用内部依赖项

c++ - C++类中的 vector 参数

OPENCV SURF 特征描述符强度