Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5 -> Qt6 problem: hidden reference to Qt5?
Forum Updated to NodeBB v4.3 + New Features

Qt5 -> Qt6 problem: hidden reference to Qt5?

Scheduled Pinned Locked Moved Solved Installation and Deployment
7 Posts 3 Posters 871 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    I'm migrating from Qt5 to Qt6.7.2.
    I have an app "qt-test" successfully built with Qt5. I've replaced references to "Qt5" with "Qt6"> Below is the qt-test CMakeLists.txt :

    find_package(
      Qt6
      COMPONENTS Gui Widgets Quick
      REQUIRED)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_AUTOUIC ON)
    
    add_executable(qt-test main.cpp ToDoModel.cpp qml.qrc)
    
    target_compile_options(qt-test PUBLIC "-Wunused-variable")
    
    target_link_libraries(qt-test PRIVATE MBGui Qt6::Core Qt6::Quick
                          mbaux)
    

    But now cmake gives this error:

    CMake Error: The INTERFACE_QT_MAJOR_VERSION property of "Qt6::Core" does
    not agree with the value of QT_MAJOR_VERSION already determined
    for "qt-test".
    

    How is QT_MAJOR_VERSION already determined for "qt-test"? I've done 'make clean' and removed CMakeCache.txt. I don't see explicit references to Qt5 in my source code. Where else should I look for references to Qt5?
    Thanks!

    1 Reply Last reply
    0
    • Tom assoT Offline
      Tom assoT Offline
      Tom asso
      wrote on last edited by Tom asso
      #7

      Thanks everyone. I believe the problem is caused by linking my app with a third-party library that was itself built with Qt5.

      1 Reply Last reply
      1
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #2

        Please add this to your ``CMakeLists.txt```

        message(STATUS "QT_MAJOR_VERSION=${QT_MAJOR_VERSION}")
        

        My guess is, that it outputs "5". In that case, configure in an empty build directory and try again.

        Software Engineer
        The Qt Company, Oslo

        Tom assoT 1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          Please add this to your ``CMakeLists.txt```

          message(STATUS "QT_MAJOR_VERSION=${QT_MAJOR_VERSION}")
          

          My guess is, that it outputs "5". In that case, configure in an empty build directory and try again.

          Tom assoT Offline
          Tom assoT Offline
          Tom asso
          wrote on last edited by Tom asso
          #3

          @Axel-Spoerl - cmake outputs the message

          QT_MAJOR_VERSION=
          

          I also print INTERFACE_QT_MAJOR_VERSION, which is also empty.
          I tried rebuilding in an empty build directory, with the same result.
          Thanks!

          1 Reply Last reply
          0
          • cristian-adamC Offline
            cristian-adamC Offline
            cristian-adam
            wrote on last edited by
            #4

            cmake --trace-expand --trace-redirect=trace.txt and have a look through trace.txt and see what CMake is doing.

            Tom assoT 1 Reply Last reply
            1
            • cristian-adamC cristian-adam

              cmake --trace-expand --trace-redirect=trace.txt and have a look through trace.txt and see what CMake is doing.

              Tom assoT Offline
              Tom assoT Offline
              Tom asso
              wrote on last edited by
              #5

              @cristian-adam - I ran cmake with --trace-expand, but I don't really know how to interpret the results.

              One thing I did learn is that my ubuntu 22.04 system contains numerous Qt5 libraries in /usr/lib/ - but I don't dare to remove them as I think that ubuntu may depend on some of them:

              $ find /usr/lib -name '*qt5*'
              /usr/lib/x86_64-linux-gnu/metatypes/qt5core_metatypes.json
              /usr/lib/x86_64-linux-gnu/metatypes/qt5gui_metatypes.json
              /usr/lib/x86_64-linux-gnu/metatypes/qt5widgets_metatypes.json
              /usr/lib/x86_64-linux-gnu/qtchooser/qt5.conf
              /usr/lib/x86_64-linux-gnu/libqt5keychain.so.1
              /usr/lib/x86_64-linux-gnu/libqca-qt5.so.2.3.4
              /usr/lib/x86_64-linux-gnu/qt5
              /usr/lib/x86_64-linux-gnu/qt5/plugins/designer/libpyqt5.so
              /usr/lib/x86_64-linux-gnu/libqca-qt5.so.2
              /usr/lib/x86_64-linux-gnu/libqt5keychain.so.0.13.2
              /usr/lib/x86_64-linux-gnu/qca-qt5
              /usr/lib/libqscintilla2_qt5.so.15.0
              /usr/lib/libqwt-qt5.so.6.1.4
              /usr/lib/libqwt-qt5.so.6
              /usr/lib/qt5
              /usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5.py
              /usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5agg.py
              /usr/lib/python3/dist-packages/matplotlib/backends/__pycache__/backend_qt5.cpython-310.pyc
              /usr/lib/python3/dist-packages/matplotlib/backends/__pycache__/backend_qt5cairo.cpython-310.pyc
              /usr/lib/python3/dist-packages/matplotlib/backends/__pycache__/backend_qt5agg.cpython-310.pyc
              /usr/lib/python3/dist-packages/matplotlib/backends/backend_qt5cairo.py
              /usr/lib/libqscintilla2_qt5.so.15
              /usr/lib/libqscintilla2_qt5.so.15.0.0
              /usr/lib/libqwt-qt5.so.6.1
              

              Thanks!

              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher referenced this topic on
              • cristian-adamC Offline
                cristian-adamC Offline
                cristian-adam
                wrote on last edited by
                #6

                It's all about CMAKE_PREFIX_PATH and also CMAKE_IGNORE_PREFIX_PATH. This is how you control where CMake would look for packages.

                You can add -D CMAKE_IGNORE_PREFIX_PATH=/usr/lib or -D CMAKE_IGNORE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu to tell CMake to ignore looking into those directories.

                In the trace log you can see what CMake is trying. If that's too much, you can look in the CMakeCache.txt to see what package found has an out of place directory.

                Compiling on Linux where you can have system packages that can interfere, is more error prone.

                1 Reply Last reply
                2
                • Tom assoT Offline
                  Tom assoT Offline
                  Tom asso
                  wrote on last edited by Tom asso
                  #7

                  Thanks everyone. I believe the problem is caused by linking my app with a third-party library that was itself built with Qt5.

                  1 Reply Last reply
                  1
                  • Tom assoT Tom asso has marked this topic as solved on

                  • Login

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