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. QPluginLoader cannot load plugin [solved]

QPluginLoader cannot load plugin [solved]

Scheduled Pinned Locked Moved General and Desktop
qpluginloaderplugin
26 Posts 5 Posters 14.8k Views
  • 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.
  • A Offline
    A Offline
    alex_malyu
    wrote on 12 May 2015, 23:15 last edited by
    #3

    There are many possible sources of problem - from poorly written plugin to plugin built with different toolchain or different CRT.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrahamL
      wrote on 13 May 2015, 07:23 last edited by
      #4

      Hi
      I found this link useful
      http://canvoki.net/Codders/qtpluginnotloading.html

      HTH

      L 1 Reply Last reply 14 May 2015, 08:08
      0
      • S SGaist
        12 May 2015, 22:10

        Hi,

        Did you setup the plugin metadata correctly ? Do you call the Q_PLUGIN_METADATA macro ?

        L Offline
        L Offline
        LeaA
        wrote on 14 May 2015, 07:59 last edited by LeaA
        #5

        @SGaist

        thank you for the answer..
        yes, I called thia macro in the class that implements the plugin interface and then I got many errors like this:
        error: undefined reference to vtable for InPluginInterface' error: undefined reference to InPluginInterface::metaObject() const'
        error: undefined reference to `InPluginInterface::qt_metacast(char const*)'

        etc. ....

        the plugin is not for qt creator, its for a project that i do with qt creator

        1 Reply Last reply
        0
        • G GrahamL
          13 May 2015, 07:23

          Hi
          I found this link useful
          http://canvoki.net/Codders/qtpluginnotloading.html

          HTH

          L Offline
          L Offline
          LeaA
          wrote on 14 May 2015, 08:08 last edited by
          #6

          @GrahamL

          this link useful for plugins for widgets..

          my plugin isn't for widget...

          G 1 Reply Last reply 14 May 2015, 08:34
          0
          • L LeaA
            14 May 2015, 08:08

            @GrahamL

            this link useful for plugins for widgets..

            my plugin isn't for widget...

            G Offline
            G Offline
            GrahamL
            wrote on 14 May 2015, 08:34 last edited by
            #7

            @LeaA

            Its hard to guess without seeing your code
            Is it possible for you to share your class definitions?

            1 Reply Last reply
            0
            • L Offline
              L Offline
              LeaA
              wrote on 14 May 2015, 08:40 last edited by
              #8

              why is the QLibraryPrivate::IsNotAPlugin (1)????

              1 Reply Last reply
              0
              • L Offline
                L Offline
                LeaA
                wrote on 14 May 2015, 08:52 last edited by LeaA
                #9

                here is the code:

                the h file of the interface:

                #ifndef INPLUGININTERFACE_H
                #define INPLUGININTERFACE_H
                #pragma once

                #include <QtPlugin>
                #include <QObject>
                #include <QtCore>

                #include "ProcessingInterface.h"
                #include "setting.h"
                #include "msstorage.h"
                #include "myplot.h"

                /**
                @brief The InPluginInterface class
                Factory of prossesingInterface
                /
                class InPluginInterface//:public QObject
                {
                // Q_OBJECT
                public:
                virtual ~InPluginInterface() = default;
                virtual std::shared_ptr <ProcessingInterface> getProcessing
                (myPlotInterface& plot,
                QVector<ReducingInterface
                > reduceData)=0;
                };

                Q_DECLARE_INTERFACE(InPluginInterface,"InPluginImp")

                #endif // INPLUGININTERFACE_H

                the h file of the class that implements the plugin:

                #ifndef INPLUGINIMP_H
                #define INPLUGINIMP_H

                #include <QtScript/QScriptEngine>
                #include <QtScript/QScriptValue>
                #include <memory>

                #include "inPluginInterface.h"
                #include "ProcessingInterface.h"
                #include "impprocessing.h"

                class Q_DECL_EXPORT InPluginImp :public QObject,public InPluginInterface
                {
                //Q_OBJECT
                Q_PLUGIN_METADATA(IID "InPluginImp")
                Q_INTERFACES(InPluginInterface)

                public:
                InPluginImp();

                ~InPluginImp()=default;
                
                // InPluginInterface interface
                
                std::shared_ptr<ProcessingInterface> getProcessing
                (myPlotInterface &plot,
                 QVector<ReducingInterface *> msStorages) override;
                

                };

                #endif // INPLUGINIMP_H

                the cpp file:

                #include "inpluginimp.h"

                InPluginImp::InPluginImp()
                {

                }

                std::shared_ptr <ProcessingInterface> InPluginImp::getProcessing
                ( myPlotInterface& plot,
                QVector<ReducingInterface*> msStorages)

                {
                std::shared_ptr <ProcessingInterface> p=std::make_shared<impProcessing>(plot ,msStorages);
                return p;
                }

                the function that loading the plugin:

                void Manager::loadPlugins()
                {
                pluginsDir = QDir(qApp->applicationDirPath());

                #if defined(Q_OS_WIN)
                if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
                pluginsDir.cdUp();
                #elif defined(Q_OS_MAC)
                if (pluginsDir.dirName() == "MacOS") {
                pluginsDir.cdUp();
                pluginsDir.cdUp();
                pluginsDir.cdUp();
                }
                #endif
                //search the file that there the plugin declared
                pluginsDir.cd("plugins");

                foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
                    QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
                  
                    QObject *plugin = loader.instance();
                
                    if (plugin) {
                
                        pluginFileNames += fileName;
                
                    }
                }
                

                }

                what is the problem here? why the QPluginLoader doesn't load the plugin? why the QLibraryPrivate::IsNotAPlugin (1)????

                thanks!

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  LeaA
                  wrote on 14 May 2015, 11:27 last edited by
                  #10

                  the problem solved

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    GrahamL
                    wrote on 14 May 2015, 11:50 last edited by
                    #11

                    Hi
                    What was the problem and how did you solve it?

                    L 1 Reply Last reply 14 May 2015, 12:15
                    0
                    • G GrahamL
                      14 May 2015, 11:50

                      Hi
                      What was the problem and how did you solve it?

                      L Offline
                      L Offline
                      LeaA
                      wrote on 14 May 2015, 12:15 last edited by LeaA
                      #12

                      @GrahamL

                      the problem was that the plugin wasn't created good and the QPluginLoader wasn't recognized it as a plugin.

                      i returned the macro Q_OBJECT to InPluginImp class and i moved the inheritance from QOBJECT to the InPluginInterface class.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        GrahamL
                        wrote on 14 May 2015, 13:01 last edited by
                        #13

                        Ah
                        Please mark the topic as SOLVED
                        Thanks

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          LeaA
                          wrote on 18 May 2015, 07:40 last edited by LeaA
                          #14

                          hi,
                          now i getting this error:
                          C:\workspace\16-5-15\src\mainProject\build-mainProject-Desktop_Qt_5_3_MinGW_32bit-Debug\VisualReceiverErrorsAnalysis\debug\moc_inpluginimp.cpp:149: error: undefined reference to `InPluginImp::InPluginImp()'

                          and this one:
                          moc_inpluginimp.cpp:-1: error: undefined reference to `InPluginImp::getProcessing(myPlotInterface&, QVector<ReducingInterface*>)'

                          collect2.exe:-1: error: error: ld returned 1 exit status

                          there is a solution for it?..

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 18 May 2015, 07:45 last edited by SGaist
                            #15

                            Did you properly implement both these functions ? Do you build the corresponding cpp file ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            L 2 Replies Last reply 18 May 2015, 07:48
                            0
                            • S SGaist
                              18 May 2015, 07:45

                              Did you properly implement both these functions ? Do you build the corresponding cpp file ?

                              L Offline
                              L Offline
                              LeaA
                              wrote on 18 May 2015, 07:48 last edited by
                              #16

                              @SGaist

                              yes..

                              1 Reply Last reply
                              0
                              • S SGaist
                                18 May 2015, 07:45

                                Did you properly implement both these functions ? Do you build the corresponding cpp file ?

                                L Offline
                                L Offline
                                LeaA
                                wrote on 18 May 2015, 07:54 last edited by
                                #17

                                @SGaist

                                it seems like a problem with the moc.cpp file of inpluginimp

                                1 Reply Last reply
                                0
                                • L Offline
                                  L Offline
                                  LeaA
                                  wrote on 18 May 2015, 08:17 last edited by
                                  #18

                                  when i putting down the Q_OBJECT macro from the inPluginImp class the errors gone but the again the first problem in this topic comming back

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 18 May 2015, 08:22 last edited by
                                    #19

                                    When adding/removing the Q_OBJECT macro, do you re-run qmake before building ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    L 2 Replies Last reply 18 May 2015, 08:24
                                    0
                                    • S SGaist
                                      18 May 2015, 08:22

                                      When adding/removing the Q_OBJECT macro, do you re-run qmake before building ?

                                      L Offline
                                      L Offline
                                      LeaA
                                      wrote on 18 May 2015, 08:24 last edited by
                                      #20

                                      @SGaist

                                      yes

                                      1 Reply Last reply
                                      0
                                      • S SGaist
                                        18 May 2015, 08:22

                                        When adding/removing the Q_OBJECT macro, do you re-run qmake before building ?

                                        L Offline
                                        L Offline
                                        LeaA
                                        wrote on 18 May 2015, 08:46 last edited by
                                        #21

                                        @SGaist

                                        it says to me that the moc_inpluginimp.cpp file isn't found..
                                        but the file is in the build directory of the project in the debuge directory

                                        1 Reply Last reply
                                        0
                                        • J Offline
                                          J Offline
                                          jalomic
                                          wrote on 18 May 2015, 09:04 last edited by
                                          #22

                                          @LeaA said:

                                          #ifndef INPLUGININTERFACE_H
                                          #define INPLUGININTERFACE_H
                                          #pragma once
                                          .....
                                          .....
                                          #endif // INPLUGININTERFACE_H

                                          T_T WTF ?

                                          L 1 Reply Last reply 18 May 2015, 09:05
                                          0

                                          12/26

                                          14 May 2015, 12:15

                                          • Login

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