Problem about qtcreator with qt5 and qt6 coexist
-
Using SurfacePro3 with windows10 1511,an old version indeed.
When i want to use qt6 with its corresponding qtcreator directly,
i find that i cannot even enter qtcreator with ERROR message from windows
i couldn't even run the maintenance tool 4.7 with the same error:
i think that was because my windows version is to low that i did not have that dll or what in my system.
and that doesn't matter, then i try to use a old version's qtcreator with qt5
and using the online installer to install qt6.3.1's MinGW,CMake to put these into the qt5's qtcreator. And i think in this way may i could use an IDE to edit qt6 project.
the line below in the following picture is the qt 6.3.1 i deploy manually.
at first i use the cmake 3.29.2 that i have in my PC originally.And i put its path in the Env Var already.It works fine with qt 5.14.2 but occur trouble with qt6.3.1 as below:
C:\Program Files\CMake\share\cmake-3.29\Modules\CMakeTestCXXCompiler.cmake:60: error: The C++ compiler "C:/Qt/Qt 6.3.1/Tools/mingw1120_64/bin/g++.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'C:/Users/Surface/AppData/Local/Temp/QtCreator-dRUsfY/qtc-cmake-bIirMBik/CMakeFiles/CMakeScratch/TryCompile-edjkpc' Run Build Command(s): "C:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 jom -f Makefile /nologo cmTC_588db\fast no such file or directory
i can't solve this promblem at all.So i decide to install anothor corresponding cmake(3.29.3 qt6.3.1 default recommend version) in the step installing qt via online installer.
And i try to create a new kit
the configuration are as below:
And the error with
C:\Program Files\CMake\share\cmake-3.29\Modules\CMakeTestCXXCompiler.cmake:60: error: The C++ compiler "C:/Qt/Qt 6.3.1/Tools/mingw1120_64/bin/g++.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'C:/Users/Surface/AppData/Local/Temp/QtCreator-dRUsfY/qtc-cmake-bIirMBik/CMakeFiles/CMakeScratch/TryCompile-edjkpc' Run Build Command(s): "C:/Program Files/CMake/bin/cmake.exe" -E env VERBOSE=1 jom -f Makefile /nologo cmTC_588db\fast no such file or directory
disappears.
But another fatal error comes.
then i check the CMakeLists.txt and find that though i create the project with qt6.3.1 kit,qtcreator still generate a qt5 version CMakeLists.txt with qt5core.
HOW should i do to solve these problems and could use Qt5's qtcreator to start programming and building qt6 project. -
SystemParametersInfoForDpi Windows API call used by the current maintenance tool: Minimum supported client Windows 10, version 1607
Qt 6 supported platforms: Windows 10 (1809 or later). Even if you could build on that Surface, or build elsewhere and deploy on the Surface, the Qt 6 executable may not work on that machine.
How should i do to solve these problems and could use Qt5's qtcreator to start programming and building qt6 project.
You are using a version of Qt Creator that predates Qt 6 (Dec 2020) released so it is incapable of generating a Qt 6 aware
qmake
orcmake
configuration.Manually create or correct the
CMakeLists.txt
. Here is a fairly generic Qt6 CMakeLists.txt for a project called myproject:cmake_minimum_required(VERSION 3.16) project(myproject 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 ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(myproject MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: # set_property(TARGET myproject APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else() if(ANDROID) add_library(myproject SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else() add_executable(myproject ${PROJECT_SOURCES} ) endif() endif() target_link_libraries(myproject PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. if(${QT_VERSION} VERSION_LESS 6.1.0) set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.myproject) endif() set_target_properties(myproject PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) include(GNUInstallDirs) install(TARGETS myproject BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) if(QT_VERSION_MAJOR EQUAL 6) qt_finalize_executable(myproject) endif()
-
Then modify the CMakeLists.txt to use Qt6Core. I don't see how Qt Creator should know which libraries you want to use.
-
@Christian-Ehrlicher Thanks.I could just modify the CMakeLists.txt and tell cmake to find Qt6core.
It works.
It's you guys that make this community so charming :D -
@ChrisW67
Yes you are right.My SurfacePro windows version is quite dowdy QAQ
I can rarely use softwares nowadays easily and compatibly with it.
But when i modify CMakeLists.txt to let it search for Qt6's libraries.
It works.
Anyhow,thank you so much for giving me your suggestion.
Love from my heart >=< -
-