Plugin system - DLLs and unresolved external symbols



  • Hi guys, I have one (big) issue creating plug-n-play system of plugins, which my app deserves...the issue is that application is missing
    external symbols, I was following step-by-step Plug-n-paint example, but I have discovered, it's a static linking. I want to create plugins via dynamic linking, is it possible, or not?



  • Of course. Plugins are dynamically linked by default.

    Please post your .pro files as well the linker error.



  • Here is it: App.pro:
    @
    QT += core gui network

    TARGET = App
    TEMPLATE = app

    SOURCES += main.cpp
    SingleApplication.cpp

    HEADERS +=
    SingleApplication.h
    @

    Linker says that:
    @
    core.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const Core::staticMetaObject" (?staticMetaObject@Core@@2UQMetaObject@@B)
    core.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Core::metaObject(void)const " (?metaObject@Core@@UBEPBUQMetaObject@@XZ)
    core.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __thiscall Core::qt_metacast(char const *)" (?qt_metacast@Core@@UAEPAXPBD@Z)
    core.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall Core::qt_metacall(enum QMetaObject::Call,int,void * *)"
    core.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void __thiscall interface::hello(void)" (?hello@interface@@UAEXXZ)(?qt_metacall@Core@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
    ........\App\bin\debug\App.Core.dll:-1: error: LNK1120: 5 unresolved externals
    @

    And library project file:
    @
    TARGET = App.Core
    TEMPLATE = lib

    CONFIG += plugin

    DEFINES += CORE_LIBRARY

    SOURCES += core.cpp

    HEADERS += core.h
    Core_global.h
    interface.h

    symbian {
    MMP_RULES += EXPORTUNFROZEN
    TARGET.UID3 = 0xE2EB6093
    TARGET.CAPABILITY =
    TARGET.EPOCALLOWDLLDATA = 1
    addFiles.sources = Core.dll
    addFiles.path = !:/sys/bin
    DEPLOYMENT += addFiles
    }

    unix:!symbian {
    maemo5 {
    target.path = /opt/usr/lib
    } else {
    target.path = /usr/lib
    }
    INSTALLS += target
    }

    @



  • hey guys, c'mon! :)...



  • Hi,

    Dont know whether this will help or not, but you can have a look in this "tutorial":http://www.voidrealms.com/viewtutorial.aspx?id=246 that explains about how to create and load plugins.



  • Without
    @CONFIG += plugin@

    you need to write such a structure before the class (or place it into header and include it if you export more than one class)

    @#ifndef CORE_LIBRARY
    #define APP_CORE_EXPORTS Q_DECL_IMPORT
    #else
    #define APP_CORE_EXPORTS Q_DECL_EXPORT
    #endif@

    and declare classes like this
    @
    class APP_CORE_EXPORTS AppCore@

    [quote author="Peppy" date="1346020550"] I want to create plugins via dynamic linking, is it possible, or not?[/quote]

    Qt plugins are dynamically loaded from their .dll/.so files by QPluginLoader so it is actually not only possible but is the case unless you use Q_IMPORT_PLUGIN.

    Hope this helps!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.