Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trying to build a Qt 6 application but getting a Qt 5 application; Qt Creator 19 on Gentoo Linux
Qt 6.11 is out! See what's new in the release blog

Trying to build a Qt 6 application but getting a Qt 5 application; Qt Creator 19 on Gentoo Linux

Scheduled Pinned Locked Moved Solved General and Desktop
qt creator 19gentoo linuxqt 6qt 5
12 Posts 5 Posters 346 Views 1 Watching
  • 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.
  • M mgoppelt

    I'm new to Qt. I selected Qt 6 in my Desktop kit. When I use ldd on the resulting binary I get
    libQt5Widgets.so.5 => /usr/lib64/libQt5Widgets.so.5 (0x00007f4decab7000)
    libQt5Gui.so.5 => /usr/lib64/libQt5Gui.so.5 (0x00007f4dec486000)
    libQt5Core.so.5 => /usr/lib64/libQt5Core.so.5 (0x00007f4debf27000)
    among other shared objects. The binary is linked to Qt 5 instead of Qt 6. My application is a normal Qt Widgets Application. There is no difference between Debug and Release in this regard. When I select Qt 5 nothing changes.

    I assume this is not the normal behavior. How can I get to the root cause of this? Where do I start to dig?

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote last edited by
    #2

    @mgoppelt
    Your paths show a Qt5 installed in /usr/lib64, which is presumably supplied by your Linux OS. Quite likely it does not supply a Qt6?

    So did you fetch and install (a pre-built) Qt6 yourself? Is your kit and build commands not picking that up and compiling/linking against the system's Qt5?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mgoppelt
      wrote last edited by
      #3

      Good point. Qt6 is also installed. The shared objects
      /usr/lib64/libQt6Core.so.6
      /usr/lib64/libQt6Gui.so.6
      /usr/lib64/libQt6Widgets.so.6
      are available. I'm quite sure that Gentoo builds Qt (both 5 and 6) from the sources.

      JonBJ 1 Reply Last reply
      0
      • M mgoppelt

        Good point. Qt6 is also installed. The shared objects
        /usr/lib64/libQt6Core.so.6
        /usr/lib64/libQt6Gui.so.6
        /usr/lib64/libQt6Widgets.so.6
        are available. I'm quite sure that Gentoo builds Qt (both 5 and 6) from the sources.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote last edited by
        #4

        @mgoppelt
        OK, so for whatever reason even though you have picked a Qt6 kit it's compiling/linking as Qt5. Someone else will doubtless know more. Does the CMakeLists.txt for the project show anything about setting for either Qt6 or Qt5?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mgoppelt
          wrote last edited by
          #5

          CMakeLists.txt doesn't restrict the build to Qt 5 or Qt 6. There appear two variables regarding the version
          ${QT_VERSION_MAJOR}
          ${QT_VERSION}
          . I will either attach CMakeLists.txt or dump it into a new reply.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mgoppelt
            wrote last edited by mgoppelt
            #6

            Here comes CMakeLists.txt:

            cmake_minimum_required(VERSION 3.16)
            
            project(Projekt_Muehle 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 20)
            set(CMAKE_CXX_STANDARD_REQUIRED ON)
            
            include_directories(${PROJECT_SOURCE_DIR})
            
            find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
            find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
            
            set(PROJECT_SOURCES
                    main.cpp
                    mainwindow.cpp
                    mainwindow.h
                    mainwindow.ui
            )
            
            if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                qt_add_executable(Projekt_Muehle
                    MANUAL_FINALIZATION
                    ${PROJECT_SOURCES}
                    add_args.h
                    add_args.cpp
                    mill_view.h mill_view.cpp
                    mill_model.h mill_model.cpp
                    mill_controller.h mill_controller.cpp
                    player.h player.cpp
                    board.h board.cpp board.ui
                    token.h token.cpp token.ui
                    board_label.h board_label.cpp board_label.ui
                    res.qrc
                )
            # Define target properties for Android with Qt 6 as:
            #    set_property(TARGET Projekt_Muehle 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(Projekt_Muehle 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(Projekt_Muehle
                        ${PROJECT_SOURCES}
                        add_args.cpp add_args.h
                        board.cpp board.h board.ui
                        board_label.cpp board_label.h board_label.ui
                        mill_controller.cpp mill_controller.h
                        mill_model.cpp mill_model.h
                        mill_view.cpp mill_view.h
                        player.cpp player.h
                        token.cpp token.h token.ui
                    )
                endif()
            endif()
            
            target_link_libraries(Projekt_Muehle 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.Projekt_Muehle)
            endif()
            set_target_properties(Projekt_Muehle 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 Projekt_Muehle
                BUNDLE DESTINATION .
                LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
                RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
            )
            
            if(QT_VERSION_MAJOR EQUAL 6)
                qt_finalize_executable(Projekt_Muehle)
            endif()
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote last edited by
              #7

              Hi,

              Just to clear things out, can you properly build that project on the command line for each version of Qt ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mgoppelt
                wrote last edited by
                #8

                I could only get a Qt 5 build using cmake and ninja.

                First cmake:

                markus@ryzen ~/Qt/Projekt_Muehle $ cmake -G Ninja -S Qt/ -B Qt/build/test_build/
                -- The CXX compiler identification is GNU 15.2.1
                -- Detecting CXX compiler ABI info
                -- Detecting CXX compiler ABI info - done
                -- Check for working CXX compiler: /usr/bin/c++ - skipped
                -- Detecting CXX compile features
                -- Detecting CXX compile features - done
                -- Configuring done (0.2s)
                -- Generating done (0.0s)
                -- Build files have been written to: /home/markus/Qt/Projekt_Muehle/Qt/build/test_build
                

                Then ninja:

                markus@ryzen ~/Qt/Projekt_Muehle/Qt/build/test_build $ ls
                build.ninja  CMakeCache.txt  CMakeFiles  cmake_install.cmake
                markus@ryzen ~/Qt/Projekt_Muehle/Qt/build/test_build $ ninja
                [13/13] Linking CXX executable Projekt_Muehle
                

                The files build.ninja and CMakeCache.txt only contain references to Qt 5:

                markus@ryzen ~/Qt/Projekt_Muehle/Qt/build/test_build $ grep LINK_LIBRARIES build.ninja
                  LINK_LIBRARIES = /usr/lib64/libQt5Widgets.so.5.15.18  /usr/lib64/libQt5Gui.so.5.15.18  /usr/lib64/libQt5Core.so.5.15.18
                markus@ryzen ~/Qt/Projekt_Muehle/Qt/build/test_build $ grep -e Qt5Widgets -e Qt5Gui -e Qt5Core CMakeCache.txt
                //The directory containing a CMake configuration file for Qt5Core.
                Qt5Core_DIR:PATH=/usr/lib64/cmake/Qt5Core
                //The directory containing a CMake configuration file for Qt5Gui.
                Qt5Gui_DIR:PATH=/usr/lib64/cmake/Qt5Gui
                //The directory containing a CMake configuration file for Qt5Widgets.
                Qt5Widgets_DIR:PATH=/usr/lib64/cmake/Qt5Widgets
                markus@ryzen ~/Qt/Projekt_Muehle/Qt/build/test_build $ grep -e Qt6Widgets -e Qt6Gui -e Qt6Core CMakeCache.txt
                

                These two files were generated by Qt Creator prior to me using the command line:

                markus@ryzen ~/Qt/Projekt_Muehle/Qt $ ls CMakeLists.txt .qtcreator/CMakeLists.txt.user 
                CMakeLists.txt  .qtcreator/CMakeLists.txt.user
                

                I don't think the second file is relevant for the command line cmake.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mgoppelt
                  wrote last edited by
                  #9

                  Is there a way to insert a code segment without automatic coloring?

                  GrecKoG Christian EhrlicherC 2 Replies Last reply
                  0
                  • M mgoppelt

                    Is there a way to insert a code segment without automatic coloring?

                    GrecKoG Offline
                    GrecKoG Offline
                    GrecKo
                    Qt Champions 2018
                    wrote last edited by
                    #10

                    @mgoppelt said in Trying to build a Qt 6 application but getting a Qt 5 application; Qt Creator 19 on Gentoo Linux:

                    Is there a way to insert a code segment without automatic coloring?

                    ```text
                    your log
                    ```

                    1 Reply Last reply
                    1
                    • M mgoppelt

                      Is there a way to insert a code segment without automatic coloring?

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote last edited by
                      #11

                      @mgoppelt And did you install the Qt6 development packages? Remove Qt5 from the CMakeLists.txt and start over with a clean build dir after you made sure the dev packages for Qt6 are installed (and even better - the dev packages for Qt5 are uninstalled).

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

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mgoppelt
                        wrote last edited by
                        #12

                        I have the development packages for Qt5 and Qt6. As you mentioned it works when I remove Qt5 from the following statement in CMakeLists.txt.

                        #find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
                        #find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets)
                        find_package(QT NAMES Qt5 REQUIRED COMPONENTS Widgets)
                        
                        

                        The first and third line result in a Qt5 build. The second line results in a Qt6 build. The "Qt version" field in my kit seems to have no influence. I set the value to "None".

                        The issue is resolved. However in a weird way.

                        1 Reply Last reply
                        0
                        • M mgoppelt has marked this topic as solved

                        • Login

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