Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Problem about qtcreator with qt5 and qt6 coexist
Forum Updated to NodeBB v4.3 + New Features

Problem about qtcreator with qt5 and qt6 coexist

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
6 Posts 3 Posters 933 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    damedameu
    wrote on last edited by aha_1980
    #1

    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:
    040d5756-794e-42de-8cff-a5502d1bb28a-image.png
    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.
    db34db98-cea9-4426-8d09-9581817a49d7-image.png
    the line below in the following picture is the qt 6.3.1 i deploy manually.
    14457216-8cad-4b58-9c85-392a716b4ada-image.png
    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:
    42a39b74-9929-4aff-ab5b-ab9a5970a348-image.png
    e1e75557-27bb-4400-998b-896eaa33b443-image.png
    b67862a0-ac96-47a9-9590-29c353578070-image.png
    9b7b6376-3deb-4622-8d0e-482585562cbf-image.png
    8435269a-500e-446a-a3de-d4f8d7ad4161-image.png
    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.
    6b31abee-2b57-4595-92bf-73bfeb0fcd06-image.png
    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.
    44b13e91-9a64-4138-b4ee-28acdba1dde7-image.png
    HOW should i do to solve these problems and could use Qt5's qtcreator to start programming and building qt6 project.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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 or cmake 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()
      
      D 1 Reply Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Then modify the CMakeLists.txt to use Qt6Core. I don't see how Qt Creator should know which libraries you want to use.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        D 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          Then modify the CMakeLists.txt to use Qt6Core. I don't see how Qt Creator should know which libraries you want to use.

          D Offline
          D Offline
          damedameu
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          0
          • C ChrisW67

            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 or cmake 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()
            
            D Offline
            D Offline
            damedameu
            wrote on last edited by
            #5

            @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 >=<

            1 Reply Last reply
            0
            • D damedameu has marked this topic as solved on
            • D damedameu has marked this topic as unsolved on
            • D Offline
              D Offline
              damedameu
              wrote on last edited by
              #6

              Hi guys,when i run the example project,there is another error which tells me that I dont have Qt platform plugin.
              As below:

              image.png

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved