Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Access Qt plugin classes from other plugins

    General and Desktop
    qtplugin shared library symbol table symbol export
    2
    4
    1066
    Loading More Posts
    • 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.
    • J
      Joshua195 last edited by

      Hi, I am loading a few shared object plugins using QPluginLoader from some subdirs:

      myInterface.h
      myPluginLoader.h

      -pluginA/interfaceA.h
      -pluginA/implemA.h

      -pluginB/interfaceB.h
      -pluginB/implemB.h

      etc.

      How do I get my pluginB to use classes from pluginA? I have no problem loading the plugins and calling their interface functions from myPluginLoader.h

      In implemB.h, I have included ../pluginA/implemA.h and tried to initialize the implemA class, but I get "symbol lookup error" and "undefined symbol: _ZN6implemAC1ERKd"

      I figure this is probably because I am linking pluginA to the base (myInterface/myPluginLoader etc.) but not linking pluginA to pluginB (and thus getting name mangling). I tried to export implemA using Q_DECL_EXPORT as:

      class Q_DECL_EXPORT implemA
      { ... }
      

      and

      class Q_DECL_IMPORT implemB
      { ... }
      

      as described here: QT Doc Creating Shared Libraries
      but that gave me the same problem. Any idea how to resolve this?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welome to devnet,

        If you have several plugins using shared code then the most simple thing to do is move all the common code in a shared lib that you will link to all the plugins using them.

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

        J 1 Reply Last reply Reply Quote 0
        • J
          Joshua195 @SGaist last edited by

          @SGaist Thanks for the response!

          I assume the plugins would link to the shared code in the usual way (-Lshared/path -lsharedlib)?

          Is having plugins with dependencies on one another generally considered bad practice?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            That assumption is corrected.

            AFAIK, having linking dependencies between two plugins is not a clean design.

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post