connection not found with mingw and cmake
-
Hi,
I converted my Qt project from qmake to cmake with out any problems. With linux (xubuntu) I can sucessful compile my programme and it works fine.
If I switch to windows 10 (Qt 5.15 with mingw 8.1 64bit) I will get a lot ofQObject::connect: signal not found in lib::datad::EnumeratorDecorator QObject::connect: signal not found in lib::datad::EnumeratorDecorator QObject::connect: signal not found in lib::datad::EnumeratorDecorator QObject::connect: signal not found in lib::datad::EnumeratorDecorator QObject::connect: signal not found in lib::datad::KoordinatenDecorator
and my application doesn't work.
Do you have a solution for this problem?
Thank you for your help.
BR
martin -
@msauer75 said in connection not found with mingw and cmake:
target_compile_definitions(${LIB} PUBLIC ${LIBDEF})
This is wrong since LIBGC_LIBRARY must only be defined when compiling the library, not when using it. See the cmake documentation --> replace PUBLIC with PRIVATE
-
This has nothing to do with qmake or cmake. You have to export the classes you use from a library on windows: https://doc.qt.io/qt-5/sharedlibrary.html
-
Ok.
My CMakeLists.txt
set(LIBDEF "LIBGC_LIBRARY") target_compile_definitions(${LIB} PUBLIC ${LIBDEF})
In my libraries I have the following include:
#ifndef LIBGC_GLOBAL_H #define LIBGC_GLOBAL_H #include <QtCore/qglobal.h> #if defined(LIBGC_LIBRARY) # define LIBGCSHARED_EXPORT Q_DECL_EXPORT #else # define LIBGCSHARED_EXPORT Q_DECL_IMPORT #endif #endif // LIBGC_GLOBAL_H
The class definition:
class LIBGCSHARED_EXPORT Cache : public QObject { Q_OBJECT Q_PROPERTY(lib::datad::IntDecorator *ui_anzgc READ GetAnz CONSTANT) Q_PROPERTY(lib::datad::IntDecorator *ui_pos READ GetPos CONSTANT) [...] };
This is the same, which I did in the qmake project.
BR
martin -
@msauer75 said in connection not found with mingw and cmake:
target_compile_definitions(${LIB} PUBLIC ${LIBDEF})
This is wrong since LIBGC_LIBRARY must only be defined when compiling the library, not when using it. See the cmake documentation --> replace PUBLIC with PRIVATE