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. Shared library dependencies in plugins
QtWS25 Last Chance

Shared library dependencies in plugins

Scheduled Pinned Locked Moved General and Desktop
qpluginloadershared libraryplugins
4 Posts 2 Posters 2.9k 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.
  • R Offline
    R Offline
    Resurr3ction
    wrote on 29 Jul 2015, 18:59 last edited by Resurr3ction
    #1

    This is not so much of a question but rather a request for clarification. My typical subdirs project in Qt Creator looks something like this:

    app
    libCommon
    libOther
    pluginA
    pluginB
    pluginC
    ...
    

    Basically what this does is the following:

    1. All plugin interfaces AND common classes/features required throughout the project are all in libCommon. Similarly the other libraries group classes that are required by more than one plugin. These shared libraries are depended on by other sub-projects using this code in their project file:

       win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../libs/libAACommon/release/ -llibAACommon
       else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../libs/libAACommon/debug/ -llibAACommon
       else:unix: LIBS += -L$$OUT_PWD/../../libs/libAACommon/ -llibAACommon
      
       INCLUDEPATH += $$PWD/../../libs/libAACommon
       DEPENDPATH += $$PWD/../../libs/libAACommon
      
    2. pluginA etc. are sub-projects that provide features and functionality to the program and are loaded dynamically on runtime using QPluginLoader starting with core/gui plugin(s) in the app.

    Now I have found out that if a plugin depends on a library (e.g. pluginA depends on libOther) then I HAVE to use the code above to include that library in the project file of the app or else the plugin will fail to load. So basically the app sub-project MUST include every library in the project even if it does not directly depend on it (but plugins it will directly or indirectly load do depend on it).

    This is confusing to me and I would like to know why is that and if it could be done so that the dependencies of the plugin are only loaded with it (when it is loaded) rather than being all pre-loaded with the application start.

    I do actually know of the solution and that is using QLibrary to manually load the libraries. Is there any other?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Jul 2015, 21:26 last edited by
      #2

      Hi,

      You need to have your DLL's in a path where the plugins can find them. This usually means either having them in the same folder as the application or modify the PATH environment variable in the Run panel of your project so that these DLL's can be found. On Windows you would usually have the DLL's put in the same folder as the application.

      Hope it helps

      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
      0
      • R Offline
        R Offline
        Resurr3ction
        wrote on 30 Jul 2015, 14:03 last edited by
        #3

        It seems right but unfortunately I cannot test if it is working. Whenever I remove the libraries from the main executable I cannot even compile it because it complains about the missing dependencies, e.g.

        class AAApplication : public ACGuiApplication
        

        where AAApplication is part of libCommon (internal shared library) and ACGuiApplication is part of another external shared library properly included as dependency of libCommon that builds just fine.

        But when I try to use the AAApplication in app and only include libCommon as its dependency (because it is) it fails to compile because it cannot find ACGuiApplication. Therefore I have to include all dependencies of everything in the project in the app as well or else it won't even compile (even if it could run the plugins if everything was in one place).

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Jul 2015, 19:56 last edited by
          #4

          ACGuiApplication is a symbol that comes from that other library so it's not provided by libCommon. Have a look at the link_prl and create_prl qmake options. They should provide you with all the dependencies needed automatically.

          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
          0

          3/4

          30 Jul 2015, 14:03

          • Login

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