Building C++ library with Qt5 code using CMake
-
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/
-
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.