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. QT Plugin loading problem

QT Plugin loading problem

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 1 Posters 520 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.
  • D Offline
    D Offline
    dwidmann
    wrote on last edited by
    #1

    I'm trying to create an application that uses plugins, based on How to Create Qt Plugins and Echo Plugin Example. My project compiles, but the application fails to load the plugin at runtime i.e. QPluginLoader load() returns false. I've stripped what I've been doing down to a very minimal project that is similar to the actual one and still exhibits the problem and uploaded it here. I'm using Qt 6.1 (from source) and cmake on a Linux platform. Am I doing something incorrectly / what do I need to do to fix this?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dwidmann
      wrote on last edited by
      #4

      Alright, for anyone who may be interested, I found the source of the problem!!

      What I had before, in the Interface, was this

      ...
      virtual ~FooInterface();
      ...
      

      I've changed that to this:

      ...
      virtual ~FooInterface() {}
      ...
      

      and now it works. It's those little details that get me sometimes...

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dwidmann
        wrote on last edited by dwidmann
        #2

        I'm still trying to get to the bottom of this problem, but I've discovered something useful while following Deploying Plugins:Debugging Plugins.

        Cannot load library /tmp/foo/lib/plugins/libfooplugin.so.0.1.0: (/tmp/foo/lib/plugins/libfooplugin.so.0.1.0: undefined symbol: _ZTI12FooInterface)
        QLibraryPrivate::loadPlugin failed on "/tmp/foo/lib/plugins/libfooplugin.so.0.1.0" : "Cannot load library /tmp/foo/lib/plugins/libfooplugin.so.0.1.0: (/tmp/foo/lib/plugins/libfooplugin.so.0.1.0: undefined symbol: _ZTI12FooInterface)"
        

        Also of note, references to that symbol in libfooplugin.so (nm libfooplugin.so)

        0000000000004640 W _ZN12FooInterfaceC1Ev
        0000000000004640 W _ZN12FooInterfaceC2Ev
                         U _ZN12FooInterfaceD2Ev
                         U _ZTI12FooInterface
                         U _ZTV12FooInterface
        

        So it seems that when the plugin is loaded that it fails to recognize the interface, even though both the application project and plugin project are linked against the interface project and have access to the relevant header. If I had to hazard a guess, it may have something to do with the relevant symbol being an abstract class that is only defined in a header file, but I'm not sure how to fix this.

        D 1 Reply Last reply
        0
        • D dwidmann

          I'm still trying to get to the bottom of this problem, but I've discovered something useful while following Deploying Plugins:Debugging Plugins.

          Cannot load library /tmp/foo/lib/plugins/libfooplugin.so.0.1.0: (/tmp/foo/lib/plugins/libfooplugin.so.0.1.0: undefined symbol: _ZTI12FooInterface)
          QLibraryPrivate::loadPlugin failed on "/tmp/foo/lib/plugins/libfooplugin.so.0.1.0" : "Cannot load library /tmp/foo/lib/plugins/libfooplugin.so.0.1.0: (/tmp/foo/lib/plugins/libfooplugin.so.0.1.0: undefined symbol: _ZTI12FooInterface)"
          

          Also of note, references to that symbol in libfooplugin.so (nm libfooplugin.so)

          0000000000004640 W _ZN12FooInterfaceC1Ev
          0000000000004640 W _ZN12FooInterfaceC2Ev
                           U _ZN12FooInterfaceD2Ev
                           U _ZTI12FooInterface
                           U _ZTV12FooInterface
          

          So it seems that when the plugin is loaded that it fails to recognize the interface, even though both the application project and plugin project are linked against the interface project and have access to the relevant header. If I had to hazard a guess, it may have something to do with the relevant symbol being an abstract class that is only defined in a header file, but I'm not sure how to fix this.

          D Offline
          D Offline
          dwidmann
          wrote on last edited by
          #3

          Also of interest, if I inspect the objects with ldd, something is strange; even though I specified that the plugin and app should both link against the library, I don't see libfoocore.so in the output, so presumably it didn't actually link?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dwidmann
            wrote on last edited by
            #4

            Alright, for anyone who may be interested, I found the source of the problem!!

            What I had before, in the Interface, was this

            ...
            virtual ~FooInterface();
            ...
            

            I've changed that to this:

            ...
            virtual ~FooInterface() {}
            ...
            

            and now it works. It's those little details that get me sometimes...

            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