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. [Solved] QPluginLoader and plugins loading 3rd party dll: weird search path?
Forum Updated to NodeBB v4.3 + New Features

[Solved] QPluginLoader and plugins loading 3rd party dll: weird search path?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.1k Views 1 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    My problem is the following one: I build plugins that I load with QPluginLoader.
    It works fine except that one of them is linking with a 3rd part. dll.
    And when I load it, it's looking for the dll in the same folder as QTCore4.dll

    My files are organized like this:
    @/Appdir
    /myApplication.exe
    /Qt dlls
    /plugins/
    /myPlugin1.dll
    /myPlugin2.dll
    /required_for_plugin2.dll@

    I would like myPlugin2.dll to look for it's dependencies in /plugins/. Is is possible?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      r2d3
      wrote on last edited by
      #2

      Hello,

      take a look at this "thread":http://developer.qt.nokia.com/forums/viewthread/4128/

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Peppy
        wrote on last edited by
        #3

        I think, you can set it via
        @QApplication::setLibraryPaths();@

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JulienMaille
          wrote on last edited by
          #4

          [quote author="r2d3" date="1299015415"]take a look at this "thread":http://developer.qt.nokia.com/forums/viewthread/4128/[/quote]2 points:

          1. applications look for dll in their own path first, why dlls do not look in their own path too?
          2. the idea behind this plugin architecture was to distribute all my plugins even if users do not have corresponding dll. And corresponding plugins would fail to load, exposing only the available functions.
            If I need to pre-load all possibles dlls, I have to move code related to dlls in the main app, and parse plugins_dll names to detect wich external_dll I should preload.
            Does not sound like a smart way to solve the issue.
          1 Reply Last reply
          0
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

            [quote author="Peppy" date="1299015745"]I think, you can set it via
            @QApplication::setLibraryPaths();@[/quote]Already tried that, it does not work. I think it is quite understandable because it will set library path for the main app, while the issue is on the plugin's side.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              r2d3
              wrote on last edited by
              #6

              setLibraryPath change the place plugins are searched in. The DLL is loaded by the OS, it searches it in the .EXE directory and in the PATH.

              So the solution is to preload it using its fullpath with QLibrary::load before loading the plugin.

              Search Path Used by Windows to Locate a DLL: http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx

              So another solution is to make the plugin directory the current directory, so the DLL could be found by Windows.

              [EDIT: fixed link, Volker]

              1 Reply Last reply
              0
              • R Offline
                R Offline
                r2d3
                wrote on last edited by
                #7

                So change to current directory to the plugin path, this is a more elegant solution.

                "QDir::setCurrent":http://doc.qt.nokia.com/latest/qdir.html#setCurrent

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JulienMaille
                  wrote on last edited by
                  #8

                  [quote author="r2d3" date="1299016515"]So change to current directory to the plugin path, this is a more elegant solution.

                  "QDir::setCurrent":http://doc.qt.nokia.com/latest/qdir.html#setCurrent[/quote]You rock! How did I not think of this? Simple and elegant. Thanks again

                  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