因为qt附带的qtcreator不好使,我习惯再qtcreator中创建项目再转到Clion中打开
在前些天我将qt更新到了6.6.2,然后我就发现在qtcreator中创建的项目转到clion中打开时cmake就会报错(在qtcreator中可正常使用)
这是一部分CmakeLists文件,是qtcreator自动生成的
cmake_minimum_required(VERSION 3.5)
project(hhhhh VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
main.cpp
widget.cpp
widget.h
widget.ui
)
下面是报错内容
CMake Error at CMakeLists.txt:12 (find_package):
Could not find a package configuration file provided by "QT" with any of
the following names:
Qt6Config.cmake
qt6-config.cmake
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
a directory containing one of the above files. If "QT" provides a separate
development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
我在网上查询了问题找到了两种解决方法
方法一是在CmakeLists添加set(CMAKE_PREFIX_PATH "D:\\qt\\6.6.2\\mingw_64\\")
方法二是在环境变量中添加D:\qt\6.6.2\mingw_64\bin和D:\qt\Tools\QtCreator\bin
这两种方法都可以使cmake不在报错,但是编译形成的程序一旦运行就会立马退出

我在网上查询clion的这串退出代码,搜到的结果是让我将程序动态链接的库文件复制到项目中,但是我并知道程序链接了什么文件
我尝试退回qt的版本但是不知道是什么原因,总是会在下载过程中出错


给我整进退两难了
不知道大佬们有解决办法没
不敢删了qt重下,怕下载的时候还会报上面的错,到时候连qtcreator都没得用了
在前些天我将qt更新到了6.6.2,然后我就发现在qtcreator中创建的项目转到clion中打开时cmake就会报错(在qtcreator中可正常使用)
这是一部分CmakeLists文件,是qtcreator自动生成的
cmake_minimum_required(VERSION 3.5)
project(hhhhh VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
main.cpp
widget.cpp
widget.h
widget.ui
)
下面是报错内容
CMake Error at CMakeLists.txt:12 (find_package):
Could not find a package configuration file provided by "QT" with any of
the following names:
Qt6Config.cmake
qt6-config.cmake
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
a directory containing one of the above files. If "QT" provides a separate
development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
我在网上查询了问题找到了两种解决方法
方法一是在CmakeLists添加set(CMAKE_PREFIX_PATH "D:\\qt\\6.6.2\\mingw_64\\")
方法二是在环境变量中添加D:\qt\6.6.2\mingw_64\bin和D:\qt\Tools\QtCreator\bin
这两种方法都可以使cmake不在报错,但是编译形成的程序一旦运行就会立马退出

我在网上查询clion的这串退出代码,搜到的结果是让我将程序动态链接的库文件复制到项目中,但是我并知道程序链接了什么文件
我尝试退回qt的版本但是不知道是什么原因,总是会在下载过程中出错


给我整进退两难了
不知道大佬们有解决办法没
不敢删了qt重下,怕下载的时候还会报上面的错,到时候连qtcreator都没得用了


