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. Missing autogenerated moc files (or code)
Forum Updated to NodeBB v4.3 + New Features

Missing autogenerated moc files (or code)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 391 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.
  • D Offline
    D Offline
    diecalt
    wrote on last edited by
    #1

    Hello,

    I'm building in Visual Studio 2017 a Qt 5.14 project generated with CMake 3.17.1 and I'm getting linker errors because Visual Studio can't find the moc generated code.

    I also have this project bulding succesfully with Qt 5.10, CMake 3.5.2 and Visual Studio 2015.

    Is there a new command I need to add to my cmake files?

    I have these:

    QT5_WRAP_CPP( MOC_SOURCE_FILES ${MOC_HEADER_FILES} )
    QT5_ADD_RESOURCES( QT_RESOURCES_FILES ${QT_RESOURCES} )
    QT5_WRAP_UI( QT_UI_H_FILES ${QT_UI_FILES} )

    Am I missing something new?

    Is there any page in the documentation with all the QT5 commands available in CMake?

    Thank you!
    Diego

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      There is a full cmake tutorial in Qt documentation: link.

      To build a Qt app it should be enough to just set:

      find_package(Qt5 COMPONENTS Core Widgets etc... REQUIRED)
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      

      You don't need to call any of the QT5_WRAP functions.

      (Z(:^

      1 Reply Last reply
      3
      • D Offline
        D Offline
        diecalt
        wrote on last edited by
        #3

        Thank you sierdzio!

        I created a small Qt application following the instructions in the tutorial and it worked with my Qt, CMake and Visual Studio combination :)

        Now I'll start fixing my project.

        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