QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe
QPluginloader error: "Cannot load library: The specified module could not be found" unless the plugin is in the same folder as in .exe
我在使用 QPluginloader
加载插件时遇到奇怪的错误。我总共构建了 4 个插件,所有插件都指定为 Q_PLUGIN_METADATA
、Q_OBJECT
和 Q_INTERFACES
。我可以看到所有插件都已正确构建,并且没有丢失 .dll(使用 Dependency walker 检查)。所有这些插件都放在单独的“插件”文件夹中。
在加载时,可以毫无问题地加载2个插件。其他 2 个插件抛出标题中提到的错误。如果我使用 .exe 将插件 dll 及其所有依赖项复制到同一文件夹中,QPluginloader 会很好地加载插件。
我错过了什么?
我在 Win 10 x64 上使用 Qt 5.7 和 VS 2015
正在通读 Dynamic-Link Library Search Order i found out it is possible to modify the search order using SetDllDirectoryA()
as described here。终于成功了。
SetDllDirectoryA((LPCSTR) "path/to/plugin/folder");
Windows 现在将搜索指定插件目录中的所有插件依赖项,否则永远不会搜索。
还可以找到有关此问题的更多信息here
我在使用 QPluginloader
加载插件时遇到奇怪的错误。我总共构建了 4 个插件,所有插件都指定为 Q_PLUGIN_METADATA
、Q_OBJECT
和 Q_INTERFACES
。我可以看到所有插件都已正确构建,并且没有丢失 .dll(使用 Dependency walker 检查)。所有这些插件都放在单独的“插件”文件夹中。
在加载时,可以毫无问题地加载2个插件。其他 2 个插件抛出标题中提到的错误。如果我使用 .exe 将插件 dll 及其所有依赖项复制到同一文件夹中,QPluginloader 会很好地加载插件。
我错过了什么?
我在 Win 10 x64 上使用 Qt 5.7 和 VS 2015
正在通读 Dynamic-Link Library Search Order i found out it is possible to modify the search order using SetDllDirectoryA()
as described here。终于成功了。
SetDllDirectoryA((LPCSTR) "path/to/plugin/folder");
Windows 现在将搜索指定插件目录中的所有插件依赖项,否则永远不会搜索。
还可以找到有关此问题的更多信息here