/usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:273 (find_package) 处的 CMake 警告:

/usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:273 (find_package) 处的 CMake 警告:

使用Qt 5.7.0+cmake编译C++程序,出现错误:C

Make Warning at /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:273 (find_package):
  Could not find a package configuration file provided by "Qt5Widget" with
  any of the following names:

    Qt5WidgetConfig.cmake
    qt5widget-config.cmake

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


CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:275 (message):
  Can not use "Widget" module which has not yet been found.
Call Stack (most recent call first):
  CMakeLists.txt:23 (qt5_use_modules)


-- Configuring incomplete, errors occurred!
See also "/home/allanna/code/OpenCV2_test/colortest/build/CMakeFiles/CMakeOutput.log".

My CMakeLists.txt


cmake_minimum_required(VERSION 3.0.0)

project(colortest)

set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/cmake/Qt5")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -02 -pthread -fPIE")
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST)

file(GLOB SRCS *.h *.hpp *.c *.cc *.cpp)
add_executable(${PROJECT_NAME} ${SRCS} ${SRC_LIST} ${ui_FILES} ${qrc_FILES})

find_package(OpenCV REQUIRED)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Gui)
find_package(Qt5OpenGL)
find_package(Qt5Xml)

qt5_use_modules(${PROJECT_NAME} Core Widget OpenGL Gui Xml)

qt5_wrap_ui(ui_FILES mainwindow.ui)
qt5_add_resources(qrc_FILES colortest.src)

我有点困惑,我在网上搜索了几种解决方案,但对我不起作用。为什么问题旁边会出现 -1?无论如何,请帮忙。谢谢。

答案1

我拼错了一个单词:小部件

qt5_use_modules(${PROJECT_NAME} 核心小部件OpenGL Gui Xml)

应该

qt5_use_modules(${PROJECT_NAME} 核心小部件OpenGL Gui Xml)

相关内容