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. QPlugin failing to load
Qt 6.11 is out! See what's new in the release blog

QPlugin failing to load

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 566 Views 2 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    I am trying to use QPlugin to load my .so files. However, at load time (of my Poodle .so) I get this error:

    undefined symbol: _ZN15Dog_Base16staticMetaObjectE)"
    

    My relevant classes are: Animal_Base, which is the ancestor of Dog_Base, which is the ancestor of Poodle. Animal_Base inherits QObject, and all three of the above have the Q_OBJECT macro in them.

    I have read countless posts about ensuring MOC runs, etc. I have followed all the guides/examples I can find, rerun qmake and cleaned out build dirs. However, I'm wondering if I'm not meeting a prerequisite to use QPlugIn. In particular:

    My base class is NOT just an interface, it has a number of methods that are defined, some are virtual, and some are pure virtual. Is that a factor?

    Is this cause of my problem? Must the class X reference by Q_DECLARE_INTERFACE(X) contain ONLY pure virtual methods? If so, does that mean I must use QLibrary instead?

    I tried loading the .so using QLibary.load and get the same error

    1 Reply Last reply
    0
    • SGaistS SGaist

      @ocgltd what is the issue with an abstract class ?

      Building a library has nothing to do with using or not abstract classes.

      However, building a plugin does. The interface which defines the plugin API is an abstract class yes. How would you implement a plugin without knowing what to implement ?

      ocgltdO Offline
      ocgltdO Offline
      ocgltd
      wrote on last edited by ocgltd
      #11

      @SGaist Well I solved it...for anyone else interested.

      Although my poodle.so compiled fine, I had not linked in the Dog_Base and Animal_Base classes to the .so. Again - NO error on compilation. But, when I tried to load the poodle.so it could not find the ctor for the base class - because it was not linked in to the library's .so

      Very strange error...but solved!

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Is Animal_Base the interface class as well ?
        If so, that is the main issue, your plugins should inherit from QObject and the interface.

        See here

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

        ocgltdO 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Is Animal_Base the interface class as well ?
          If so, that is the main issue, your plugins should inherit from QObject and the interface.

          See here

          ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by ocgltd
          #3

          @SGaist Animal_Base has a mix of defined methods, virtual methods, and pure virtual. Dog_Base just declares a couple more methods, and overrides a virtual method.

          However, trying to load the .so with QLibrary.load causes the exact same problem. So are you saying that any .so (that is a class) must derive from an interface??

          This is my first attempt at creating a .so file, so I'm new to all of this. I just can't figure out why derivation from an interface is important.

          SGaistS 1 Reply Last reply
          0
          • ocgltdO ocgltd

            @SGaist Animal_Base has a mix of defined methods, virtual methods, and pure virtual. Dog_Base just declares a couple more methods, and overrides a virtual method.

            However, trying to load the .so with QLibrary.load causes the exact same problem. So are you saying that any .so (that is a class) must derive from an interface??

            This is my first attempt at creating a .so file, so I'm new to all of this. I just can't figure out why derivation from an interface is important.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #4

            The concept of a plugin is to have an interface which defines the common set of methods usually as pure virtual in a dynamic library.

            Then each plugin implements that interface and links to that library.

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

            ocgltdO 1 Reply Last reply
            0
            • SGaistS SGaist

              The concept of a plugin is to have an interface which defines the common set of methods usually as pure virtual in a dynamic library.

              Then each plugin implements that interface and links to that library.

              ocgltdO Offline
              ocgltdO Offline
              ocgltd
              wrote on last edited by ocgltd
              #5

              @SGaist To keep life simple (while I'm learning) I'll switch to QLibrary to load my .so

              But the error occurs with QLibrary.load too. Can I fix this error without making the base class abstract? It just seems weird that every .so implementation must be derived from an abstract class

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Did you change the interface class as shown in the documentation ?

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

                ocgltdO 1 Reply Last reply
                0
                • SGaistS SGaist

                  Did you change the interface class as shown in the documentation ?

                  ocgltdO Offline
                  ocgltdO Offline
                  ocgltd
                  wrote on last edited by ocgltd
                  #7

                  @SGaist I did not want to use an interface class (assuming that means the ancestor must be abstract). I read the QLibrary & Shared Libary pages, but did not see anywhere that the base class must be abstract.

                  Aside from that, I think my class follows the documentation. I've also been following this StackOverflow post for clues.

                  I've been going in circles for 5 hours on this one. I must be missing some concept.

                  SGaistS 1 Reply Last reply
                  0
                  • ocgltdO ocgltd

                    @SGaist I did not want to use an interface class (assuming that means the ancestor must be abstract). I read the QLibrary & Shared Libary pages, but did not see anywhere that the base class must be abstract.

                    Aside from that, I think my class follows the documentation. I've also been following this StackOverflow post for clues.

                    I've been going in circles for 5 hours on this one. I must be missing some concept.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @ocgltd a plugin has a different purpose than a shared library.

                    Please check again the documentation about the plugins I linked above. There are several examples that shows how to implement them for extending a Qt application.

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

                    ocgltdO 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      @ocgltd a plugin has a different purpose than a shared library.

                      Please check again the documentation about the plugins I linked above. There are several examples that shows how to implement them for extending a Qt application.

                      ocgltdO Offline
                      ocgltdO Offline
                      ocgltd
                      wrote on last edited by ocgltd
                      #9

                      @SGaist I've read the page many times, and in their example "FilterInterface" (the base class) is abstract.

                      That's why I abandoned QPlugin and just want to load the .so with QLibrary. I don't want to use an abstract base class. (Unless you are saying an SO class must be based on an abstract class??)

                      However, I think that's where I'm getting stuck. I'm missing some important concept. I confirmed with 'nm' that the symbol mentioned in the runtime error is NOT in the moc_X.cpp file. Why?

                      I appreciate the help!

                      SGaistS 1 Reply Last reply
                      0
                      • ocgltdO ocgltd

                        @SGaist I've read the page many times, and in their example "FilterInterface" (the base class) is abstract.

                        That's why I abandoned QPlugin and just want to load the .so with QLibrary. I don't want to use an abstract base class. (Unless you are saying an SO class must be based on an abstract class??)

                        However, I think that's where I'm getting stuck. I'm missing some important concept. I confirmed with 'nm' that the symbol mentioned in the runtime error is NOT in the moc_X.cpp file. Why?

                        I appreciate the help!

                        SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        @ocgltd what is the issue with an abstract class ?

                        Building a library has nothing to do with using or not abstract classes.

                        However, building a plugin does. The interface which defines the plugin API is an abstract class yes. How would you implement a plugin without knowing what to implement ?

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

                        ocgltdO 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          @ocgltd what is the issue with an abstract class ?

                          Building a library has nothing to do with using or not abstract classes.

                          However, building a plugin does. The interface which defines the plugin API is an abstract class yes. How would you implement a plugin without knowing what to implement ?

                          ocgltdO Offline
                          ocgltdO Offline
                          ocgltd
                          wrote on last edited by ocgltd
                          #11

                          @SGaist Well I solved it...for anyone else interested.

                          Although my poodle.so compiled fine, I had not linked in the Dog_Base and Animal_Base classes to the .so. Again - NO error on compilation. But, when I tried to load the poodle.so it could not find the ctor for the base class - because it was not linked in to the library's .so

                          Very strange error...but solved!

                          1 Reply Last reply
                          0
                          • ocgltdO ocgltd has marked this topic as solved on

                          • Login

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