Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Missing autogenerated moc files (or code)



  • 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


  • Moderators

    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.



  • 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.


Log in to reply