Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Plugin won't load [Solved]
Forum Updated to NodeBB v4.3 + New Features

Plugin won't load [Solved]

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 6.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gourmand
    wrote on last edited by
    #1

    Interface class declared:
    @class QApplication;

    class _interface
    {
    public:
    virtual ~_interface();
    virtual void start_plugin( QApplication* ) = 0;
    };

    Q_DECLARE_INTERFACE( _interface, "ru.home.plugin._interface/1.5")
    @

    Class declared
    @
    #include <QObject>
    #include "_interface.h"

    class QApplication;

    class main_plugin : public QObject, public _interface {
    Q_OBJECT
    Q_INTERFACES( _interface )

    public:
    virtual ~main_plugin(){}
    virtual void start_plugin( QApplication * );
    };@

    Class implemented
    @MainWindow glpMainWindow;
    void main_plugin::start_plugin( QApplication
    a )
    {
    glpMainWindow = new MainWindow( a );
    glpMainWindow->show();
    return;
    }

    Q_EXPORT_PLUGIN2( _interface, main_plugin )@

    .pro file beginning for plugin
    @TARGET = pluginapp
    TEMPLATE = lib
    CONFIG += plugin@

    plugin loading inside parent application:
    @ QDir dir( QApplication::applicationDirPath() );
    QPluginLoader PluginLoader( dir.absoluteFilePath("pluginapp.dll") );
    QObject* pluginapp = qobject_cast<QObject*>( PluginLoader.instance() );@

    pluginapp is NULL nothing more hapiness,
    pluginapp.dll definetely exists in main app folder
    the call of QString errstr = PluginLoader.errorString(); after this gives errstr == "Unknown error"

    stall... what's wrong? how to define error?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gourmand
      wrote on last edited by
      #2

      I made empty plugin, without useful code and tried this:

      @ a->addLibraryPath( a->applicationDirPath() );
      QPluginLoader PluginLoader( "EmptyPlugin.dll" /abspath/ );
      QObject* CI_FED = qobject_cast<QObject*>( PluginLoader.instance() );@

      same effect, dead end...

      ANYBODY KNOWING Qt PLUGINS - PLEASE HELP!

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Gourmand
        wrote on last edited by
        #3

        @ QPluginLoader PluginLoader();
        PluginLoader.setFileName( "EmptyPlugin.dll" );
        QString plugname = PluginLoader.fileName();@

        plugname is empty... what is going on here??? :-0

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gourmand
          wrote on last edited by
          #4

          Even the code
          @ QPluginLoader PluginLoader("I:\Qt\2010.05s\projects\SCPS-M-build-desktop\debug\pluginapp.dll");
          QString abspath = PluginLoader.fileName();@
          or
          @ QPluginLoader PluginLoader("I:/Qt/2010.05s/projects/SCPS-M-build-desktop/debug/pluginapp.dll");
          QString abspath = PluginLoader.fileName();@

          doesn't work, abspath is empty but the file pluginapp.dll definitely exists and path is correct

          ANYBODY CAN CONFIRM OR DECLINE THIS?

          I'm going post bug report...

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Gourmand
            wrote on last edited by
            #5

            SOLVED. Application was made static because of wrong Qt selected in it's project. Dynamically linked plugins don't work with static applications.

            But the error message must be more informative. It would save my time.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              [quote author="Gourmand" date="1307541728"]SOLVED. Application was made static because of wrong Qt selected in it's project. Dynamically linked plugins don't work with static applications.

              But the error message must be more informative. It would save my time.
              [/quote]

              Reading docs saves time as well. It's clearly stated at least in the "plugins howto":http://doc.qt.nokia.com/4.7/plugins-howto.html#static-plugins and in the "deployment guide":http://doc.qt.nokia.com/latest/deployment.html#static-vs-shared-libraries

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Gourmand
                wrote on last edited by
                #7

                I read this all and remembered plugins are only for dynamic linking. But if only QPluginLoader told me error state "Plugins are not supported in static application" - then I'd solve problem much earlier. The bug is in error processing code in QPluginLoader. It returns wrong error state: "Unknown error".

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved