QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe
-
@SGaist said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
Sadly it looks like Windows does not have that feature.
Which feature do you mean?
-
@kshegunov It didn't work. We are running out of options aren't we? I still believe there must be a way to deal with this. I don't think big applications put all their dependencies in one place (application directory) so that windows can find them at run-time.
I preferred to build plugins the Qt-way because it is a bit easier to integrate into my Qt application. Now, i realize even, if i use
boost.dll
to load plugins i will again run into this issue of windows not able to find the dependencies since it is an OS issue now. Or am i wrong? -
@MarKS said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
I preferred to build plugins the Qt-way because it is a bit easier to integrate into my Qt application. Now, i realize even, if i use
boost.dll to build plugins i will again run into this issue of windows not able to find the dependencies since it is an OS issue now. Or am i wrong?Well I'm pretty much out of ideas. A few years back (or at least to my knowledge) MS introduced SxS which is/was supposed to combat this particular problem, however I personally have no experience in deploying with it.
Additional link: https://docs.microsoft.com/en-us/windows/win32/sbscs/isolated-applications-and-side-by-side-assemblies-portal
-
@kshegunov said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
@SGaist said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
Sadly it looks like Windows does not have that feature.
Which feature do you mean?
RPATH equivalent
@MarKS one other possibility could be to use a script to start your application that would first set the PATH environment variable to include the folders of your plugins.
-
The goal of the script is to change the PATH locally for the script and start your application as well. Just like it's done by Firefox on Linux to ensure the bundled libraries are found.
-
@SGaist said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
The goal of the script is to change the PATH locally for the script and start your application as well. Just like it's done by Firefox on Linux to ensure the bundled libraries are found.
I don't believe that's going to work (properly), because to have this work the expected way the PATH should be modified between loading of the plugins, not at the time the executable is loaded ...
@MarKS, two more (rather more obvious suggestions):
- Rename the dlls and libs each plugin uses, so the loader knows what to map where and link the plugin to each of the ones it needs. You can apply this with the usual deployment - put everything in the app dir. Granted it's not very clean, but it's (almost) guaranteed to work.
or
- (And I hate myself for suggesting this, but we live in interesting times ...)
Link statically the libraries in the plugin. If you decide to go this way, do not forget to compile the libraries yourself and enable/GL
on compilation and/LTCG
at link time to have the MSVC do the LTO so you don't get overly fat binaries.
-
For number 2: only the non Qt stuff. Otherwise you'll have interesting issues with the QObject based classes meta object having multiple copies.
-
While reading through Dynamic-Link Library Search Order i found out it is possible to modify the search order using
SetDllDirectoryA()
as described here. It finally worked.Although, this would still be half the answer as it will fail in Linux or Mac. I believe there should be a way to achieve this in Linux but right now i am happy with windows. If you guys know how to achieve this in Linux or Mac please feel free to add your answer here.
Would help others.
-
@SGaist said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
For number 2: only the non Qt stuff. Otherwise you'll have interesting issues with the QObject based classes meta object having multiple copies.
Yes, yes, that's what I meant, I'm just not that good with putting words in place of thoughts ... ;)
@MarKS said in QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe:
If you guys know how to achieve this in Linux or Mac please feel free to add your answer here.
On Linux you can just modify the RPATH for the plugin binary. Should work out of the box.