[Interest] Problems with CMake and static Qt plugins

NoRulez norulez at me.com
Fri Mar 2 14:48:03 CET 2012


Hello,

I use Qt 4.8.0 from the QtSDK and I want to generate a static qt plugin.
In my main.cpp I have the following:


#include <QApplication>
#include <QtPlugin>

Q_IMPORT_PLUGIN(Local)

int main(int argc, char* argv[]) {
    QApplication app(argc, argv);

    .
    .
    .
    return app.exec();

}

The corresponding CMakeLists.txt for the LocalPlugin looks like the following:

SET(LOCALPLUGIN_HEADERS

    LocalPlugin.h

)

SET(LOCALPLUGIN_SOURCES

    LocalPlugin.cpp

)


SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTPLUGIN TRUE)

QT4_AUTOMOC(${LOCALPLUGIN_SOURCES})
QT4_WRAP_CPP(LOCALPLUGIN_MOC ${LOCALPLUGIN_HEADERS})

ADD_LIBRARY(Local STATIC ${LOCALPLUGIN_HEADERS} ${LOCALPLUGIN_SOURCES} ${LOCALPLUGIN_MOC})

TARGET_LINK_LIBRARIES(Local ${QT_LIBRARIES})


The corresponding CMakeLists.txt for the main app looks like the following:

SET(QT_USE_QTMAIN TRUE)

SET(QT_USE_QTGUI TRUE)

ADD_EXECUTABLE(MyApp WIN32 ${APP_SOURCES} ${APP_RCC} MyApp.rc)
TARGET_LINK_LIBRARIES(MyApp Local ${QT_LIBRARIES})

When I compile it I get the following error:
In function `StaticLocalPluginInstance': undefined reference to `qt_plugin_instance_Local()'

Please, could anybody help me to get it working?

Thanks in advance

Best Regards
NoRulez

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120302/44c551dc/attachment.html>


More information about the Interest mailing list