Abstract plugin inheritance error
-
Roughly :
pluginfoo.pro
QT += 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.json
mycoollib.pro
QT += core gui TARGET = mycoollib TEMPLATE = lib DESTDIR = $$OUTPWD/lib INCLUDEPATH += . SOURCES += \ abstractplugin.cpp HEADERS += \ plugininterface.hpp abstractplugin.hpp
myproject.pro
QT += 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.hpp
Project structure
mycoolproject \ ---- mycoollib ---- pluginfoo ---- myproject
mycoolproject being a SUBDIR project building first mycoollib and then pluginfoo and myproject.
-
Roughly :
pluginfoo.pro
QT += 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.json
mycoollib.pro
QT += core gui TARGET = mycoollib TEMPLATE = lib DESTDIR = $$OUTPWD/lib INCLUDEPATH += . SOURCES += \ abstractplugin.cpp HEADERS += \ plugininterface.hpp abstractplugin.hpp
myproject.pro
QT += 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.hpp
Project structure
mycoolproject \ ---- mycoollib ---- pluginfoo ---- myproject
mycoolproject 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
-l
and-L
.-L
just 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
-l
and-L
.-L
just 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.hpp
it 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.hpp
it 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 manager
on theMyProjectWindow
, and I haveLIBS += -L../libs -lpluginmanager
on 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 manager
on theMyProjectWindow
, and I haveLIBS += -L../libs -lpluginmanager
on 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)
-