Access Qt plugin classes from other plugins
-
Hi, I am loading a few shared object plugins using QPluginLoader from some subdirs:
myInterface.h
myPluginLoader.h-pluginA/interfaceA.h
-pluginA/implemA.h-pluginB/interfaceB.h
-pluginB/implemB.hetc.
How do I get my pluginB to use classes from pluginA? I have no problem loading the plugins and calling their interface functions from myPluginLoader.h
In implemB.h, I have included ../pluginA/implemA.h and tried to initialize the implemA class, but I get "symbol lookup error" and "undefined symbol: _ZN6implemAC1ERKd"
I figure this is probably because I am linking pluginA to the base (myInterface/myPluginLoader etc.) but not linking pluginA to pluginB (and thus getting name mangling). I tried to export implemA using Q_DECL_EXPORT as:
class Q_DECL_EXPORT implemA { ... }
and
class Q_DECL_IMPORT implemB { ... }
as described here: QT Doc Creating Shared Libraries
but that gave me the same problem. Any idea how to resolve this?Thank you!
-
Hi and welome to devnet,
If you have several plugins using shared code then the most simple thing to do is move all the common code in a shared lib that you will link to all the plugins using them.
-
That assumption is corrected.
AFAIK, having linking dependencies between two plugins is not a clean design.