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. Could not find moc executable target Qt6::moc
Forum Updated to NodeBB v4.3 + New Features

Could not find moc executable target Qt6::moc

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 2.3k 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.
  • G Offline
    G Offline
    g1ennr
    wrote on last edited by g1ennr
    #1

    I'm trying to build linuxdeployqt and when running CMake it can't find Qt6::moc.

    CMake Error: AUTOMOC for target linuxdeployqt: Could not find moc executable target Qt6::moc
    CMake Generate step failed.  Build files cannot be regenerated correctly.
    

    The CMakeLists.txt uses set(CMAKE_AUTOMOC ON).

    I have installed Qt 6.5.3 using the maintenance tool and it works correctly for a different qmake project and qmake -query seems to be able to locate moc correctly

    $ qmake -query QT_INSTALL_LIBEXECS
    /home/glenn/Qt/6.5.3/gcc_64/libexec
    $ `qmake -query QT_INSTALL_LIBEXECS`/moc --version
    moc 6.5.3
    
    $ cmake --version
    cmake version 3.27.7
    

    What could the problem here and how can I fix or work around it?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      g1ennr
      wrote on last edited by
      #2

      Fixed with the following change in tools/linuxdeployqt/CMakeLists.txt

      #find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
      find_package(Qt6 REQUIRED COMPONENTS Core)
      
      1 Reply Last reply
      1
      • G g1ennr has marked this topic as solved on
      • S Offline
        S Offline
        Sayuqwq
        wrote on last edited by
        #3

        It did not work on my computer, and the cmake output get more complicated. It indicated a path name error when I attempted to remove 'QT' or 'NAMES' or both them.

        SGaistS 1 Reply Last reply
        1
        • S Sayuqwq

          It did not work on my computer, and the cmake output get more complicated. It indicated a path name error when I attempted to remove 'QT' or 'NAMES' or both them.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sayuqwq Hi and welcome to devnet,

          One simple way to use cmake is to in fact use the qt-cmake wrapper that is contained in the Qt 6 installation you want to use. Otherwise, use the CMAKE_PREFIX_PATH to point cmake to the Qt version you want to use.

          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
          1
          • Marcus Sonestedt - CellinkM Offline
            Marcus Sonestedt - CellinkM Offline
            Marcus Sonestedt - Cellink
            wrote on last edited by Marcus Sonestedt - Cellink
            #5
            This post is deleted!
            1 Reply Last reply
            0
            • Marcus Sonestedt - CellinkM Offline
              Marcus Sonestedt - CellinkM Offline
              Marcus Sonestedt - Cellink
              wrote on last edited by Marcus Sonestedt - Cellink
              #6

              The fix that works for me (tm) is:

              find_package(QT NAMES Qt6 Qt5)
              find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Test)
              

              Needed to use CMAKE_PREFIX_PATH for this to work. Just setting QT_DIR / QT did not.

              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