Abstract plugin inheritance error
-
Hi,
The usual setup when building a plugin based application is to have the plugin interfaces definitions and related code in a library that you will link to both the plugin and the application.
That's what is suggested here.
-
Roughly :
pluginfoo.proQT += core gui TARGET = pluginfoo TEMPLATE = lib CONFIG += plugin DESTDIR = $$OUTPWD/bin/plugins LIBS += -L$$OUTPWD/lib -lmycoollib DEFINES += QT_DEPRECATED_WARNINGS INCLUDEPATH += ../mycoollib SOURCES += pluginfoo.cpp HEADERS += pluginfoo.hpp DISTFILES += pluginfoo.jsonmycoollib.proQT += core gui TARGET = mycoollib TEMPLATE = lib DESTDIR = $$OUTPWD/lib INCLUDEPATH += . SOURCES += \ abstractplugin.cpp HEADERS += \ plugininterface.hpp abstractplugin.hppmyproject.proQT += core gui widgets xml network TARGET = myproject TEMPLATE = app DESTDIR = $$OUTPWD/bin LIBS += -L$$OUTPWD/lib -lmycoollib INCLUDEPATH += ../mycoollib DEFINES += QT_DEPRECATED_WARNINGS SOURCES += src/main.cpp \ gui/myprojectwindow.cpp HEADERS += gui/myprojectwindow.hppProject structure
mycoolproject \ ---- mycoollib ---- pluginfoo ---- myprojectmycoolproject being a SUBDIR project building first mycoollib and then pluginfoo and myproject.
-
Roughly :
pluginfoo.proQT += core gui TARGET = pluginfoo TEMPLATE = lib CONFIG += plugin DESTDIR = $$OUTPWD/bin/plugins LIBS += -L$$OUTPWD/lib -lmycoollib DEFINES += QT_DEPRECATED_WARNINGS INCLUDEPATH += ../mycoollib SOURCES += pluginfoo.cpp HEADERS += pluginfoo.hpp DISTFILES += pluginfoo.jsonmycoollib.proQT += core gui TARGET = mycoollib TEMPLATE = lib DESTDIR = $$OUTPWD/lib INCLUDEPATH += . SOURCES += \ abstractplugin.cpp HEADERS += \ plugininterface.hpp abstractplugin.hppmyproject.proQT += core gui widgets xml network TARGET = myproject TEMPLATE = app DESTDIR = $$OUTPWD/bin LIBS += -L$$OUTPWD/lib -lmycoollib INCLUDEPATH += ../mycoollib DEFINES += QT_DEPRECATED_WARNINGS SOURCES += src/main.cpp \ gui/myprojectwindow.cpp HEADERS += gui/myprojectwindow.hppProject structure
mycoolproject \ ---- mycoollib ---- pluginfoo ---- myprojectmycoolproject being a SUBDIR project building first mycoollib and then pluginfoo and myproject.
-
You don't link the plugins. You link your plugins against that common library.
Yes, you have to use both
-land-L.-Ljust tells the linker where to look at. -
You don't link the plugins. You link your plugins against that common library.
Yes, you have to use both
-land-L.-Ljust tells the linker where to look at.@SGaist It works, but I have another question now.
I named the "commonlib" to "pluginmanager" this class will hold information about plugins, load, unload and so on using
QPluginLoader, but... when I try to use it on the main application including the headerpluginmanager.hppit says that it cannot open the file, even if I have theINCLUDEPATH += ../pluginmanager. On Qt Creator it does work, I'm able to ctrl+click, etc, but when I try to compile I get this error. -
@SGaist It works, but I have another question now.
I named the "commonlib" to "pluginmanager" this class will hold information about plugins, load, unload and so on using
QPluginLoader, but... when I try to use it on the main application including the headerpluginmanager.hppit says that it cannot open the file, even if I have theINCLUDEPATH += ../pluginmanager. On Qt Creator it does work, I'm able to ctrl+click, etc, but when I try to compile I get this error. -
@Defohin Did you run qmake again after changing the pro file? After qmake you should do a complete rebuild.
@jsulm It works, but now I'm getting unresolved external symbol on the main project when trying to use
PluginManager manageron theMyProjectWindow, and I haveLIBS += -L../libs -lpluginmanageron the pro file.myprojectwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl PluginManager::PluginManager(class QObject *)" (??0PluginManager@@QEAA@PEAVQObject@@@Z) referenced in function "public: __cdecl MyProjectWindow::MyProjectWindow(class QWidget *)" (??0MyProjectWindow@@QEAA@PEAVQWidget@@@Z)
-
@jsulm It works, but now I'm getting unresolved external symbol on the main project when trying to use
PluginManager manageron theMyProjectWindow, and I haveLIBS += -L../libs -lpluginmanageron the pro file.myprojectwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl PluginManager::PluginManager(class QObject *)" (??0PluginManager@@QEAA@PEAVQObject@@@Z) referenced in function "public: __cdecl MyProjectWindow::MyProjectWindow(class QWidget *)" (??0MyProjectWindow@@QEAA@PEAVQWidget@@@Z)
-