Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Building C++ library with Qt5 code using CMake
Forum Updated to NodeBB v4.3 + New Features

Building C++ library with Qt5 code using CMake

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 4.8k 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.
  • A Offline
    A Offline
    athanase
    wrote on last edited by
    #1

    I have a library that integrates some GTK functionnalities, and I decided to switch to Qt. So I created a test cmake file to try to integrate Qt5 but it does not work because when I load the libary dynamically using an executable I get "undefined symbols".

    undefined symbol: _ZN8UIWindow16staticMetaObjectE
    I googled a lot, and it does not seems to be that simple si any kind of help, or comments would be much appreciated.

    Here are the relevant files I use: "Gist":https://gist.github.com/athanase/5524646

    Question already asked on stackoverflow: http://stackoverflow.com/questions/16398144/using-qt5-in-a-library/

    1 Reply Last reply
    0
    • A Offline
      A Offline
      athanase
      wrote on last edited by
      #2

      Ok I found the solution. Since I use different folders for the header and the source files, I have to manually specify where is the file containing the qt code.

      QT5_WRAP_CPP( MOCS_HDRS ${INCLUDE_DIR}/UIWindow.h )

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Guigui
        wrote on last edited by
        #3

        Here's the Cmake manual for Qt5 macros, if you haven't found it yet.

        "http://qt-project.org/doc/qt-5.0/qtdoc/cmake-manual.html":http://qt-project.org/doc/qt-5.0/qtdoc/cmake-manual.html

        Qt classes which use the Q_OBJECT macro must be wrapped using the QT5_WRAP_CPP macro in order to generate the moc files. As shown in the tutorial, you can also use the SET (CMAKE_AUTOMOC ON) feature, which runs the moc tool automatically when required. Additional macros also exist for .ui files and resources files.

        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