Important: Please read the Qt Code of Conduct -

Problems loading plugins

  • Hi,

    I have several plugins that are subclasses of an abstract class. Interface class exists and is declared in abstract base class.
    Plugin_Metadata macro is used in the final plugin class.

    I followed plug_and_paint example with the difference, that I have an abstract class between interface and plugin.

    Building succeeds without errors, but when I run the app, no plugin is loaded.

    Debugging the app shows some error message like:

    undefined symbol: _ZNK20AbstractCenterWidget10metaObjectEv)"

    which is the abstract class, where I declared the interface-usage.

    Following the error, I added the plugin_metadata macro to the abstract class as well, but now compilation fails as moc tries to create an instance from that abstract class, which of cause will fail.

    How can I break that tangle?

  • @django-Reinhard Too hard say something without your code. Please show declaration of your class and how you load plugin and create instance of your object

  • Well, here we go:

    first the interface:

    #include <QtPlugin>
    class QWidget;
    class QCloseEvent;
    class QShowEvent;
    class PluginPageInterface
      virtual ~PluginPageInterface() = default;
      virtual void closeEvent(QCloseEvent* e) = 0;
      virtual void showEvent(QShowEvent* e) = 0;
      virtual QWidget* createContent() = 0;
      virtual void connectSignals() = 0;
      virtual void updateStyles()   = 0;
    #define PluginPageInterface_iid "de.schwarzrot.FalconView.PluginPage/0.1"
    Q_DECLARE_INTERFACE(PluginPageInterface, PluginPageInterface_iid)

    the abstract class declaration:

    #include <QWidget>
    #include <PluginPageInterface.h>
    class CenterView;
    class SettingsNotebook;
    class QString;
    class QAction;
    class QFile;
    /*! loads widgets from uiFile and allows late initialization at page usage
    class AbstractCenterWidget : public QWidget, public PluginPageInterface
      void     initialize(const QString& fileName, const QString& name, bool addScrollArea = false);
      QAction* viewAction();
      // called by central widget stack
      virtual void closeEvent(QCloseEvent* e) override;
      virtual void showEvent(QShowEvent* e) override;
      void dataChanged(AbstractCenterWidget* w, const QVariant& changed);
      explicit AbstractCenterWidget(QWidget* parent = nullptr);
      virtual ~AbstractCenterWidget() = default;
      virtual QWidget* createContent();
      QAction*     vAction;
      QString      fileName;
      bool         addScrollArea;

    ... and here one plugin declaration:

    #include <abscenterwidget.h>
    #include <PluginPageInterface.h>
    class FixtureEdit;
    class AxisMask;
    class FixtureManager : public AbstractCenterWidget
      Q_PLUGIN_METADATA(IID "PluginPageInterface_iid" FILE "fixtureManager.json")
      FixtureManager(QWidget* parent = nullptr);
      virtual void connectSignals() override;
      virtual void updateStyles()   override;
      void activateEditor(int index);
      virtual void keyPressEvent(QKeyEvent* event) override;
      virtual void showEvent(QShowEvent *event) override;
      virtual QWidget* createContent() override;
      QWidget*  client;
      QFont     cFonts[4];
      QString   cStyle[4];
      AxisMask* axisMask;

  • I got it.

    Just as a dumb test I copied the plugin from plugandpaint sample into plugindir of my app and that got loaded.

    This showed me that the loader failures had nothing to do with my programming, but that there was a problem with the plugin files.

    So I investigated further in that direction and found out that no link errors are output at building the plugins. So if you think everything is error free, that is far from true for the plugins.

    Was then still a tough piece of work, but in the meantime all plugins get loaded.

Log in to reply