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

Linker error in static build when including qico plugin



  • I followed the guides about including qico plugin to static build but I keep getting linker error. I tried at least 10 different variants.

    .pro
    @CONFIG += static
    static {
    QTPLUGIN += qico
    DEFINES += STATIC
    message("Static build")
    }@

    main.cpp
    @#include "mainwindow.h"
    #include <QApplication>

    #ifdef STATIC
    #include <QtPlugin>
    Q_IMPORT_PLUGIN(qico)
    #endif

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    Also tried this variant
    .pro
    @CONFIG += static
    QTPLUGIN += qico@

    main.cpp
    @#include "mainwindow.h"
    #include <QApplication>

    #include <QtPlugin>
    Q_IMPORT_PLUGIN(qico)

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    Always results in linker error:
    @main.obj:-1: error: LNK2019: unresolved external symbol "struct QStaticPlugin const __cdecl qt_static_plugin_qico(void)" (?qt_static_plugin_qico@@YA?BUQStaticPlugin@@XZ) referenced in function "public: __thiscall StaticqicoPluginInstance::StaticqicoPluginInstance(void)" (??0StaticqicoPluginInstance@@QAE@XZ)@

    I also tried to manually add qico.lib to LIBS but no success.

    Platform: Windows 7
    Qt static build with:
    @configure -static -release -qmake -opensource -nomake examples -nomake tests -opengl desktop -platform win32-msvc2010
    jom@
    Then added the static build to Kits and under Projects added as build option for my project. So, building with Qt 5.2 Desktop Static Build msvc2010 win32 release.

    The linker error seems so obscure that I can't find anything with google or stackoverflow. This forum is my last resort. :|



  • Try this:
    ...
    Q_IMPORT_PLUGIN (QICOPlugin);
    ...


Log in to reply