gpt4 book ai didi

qt - 在运行时检查 Qt 插件的依赖性

转载 作者:行者123 更新时间:2023-12-01 06:14:37 26 4
gpt4 key购买 nike

这是我所拥有的:我的应用程序是用 Qt 4.5 静态编译的。我正在使用 qsqloci 插件(静态链接),它动态加载 oracle 库(oci.dll,...)。

我希望能够检查是否存在 oracle DLL,并根据结果使用或不使用插件功能。

还有问题:

  • 静态链接的插件是否可能?
  • 如果不是,是否可以动态链接插件(应用程序的其余部分仍然静态链接到 Qt)?
  • 如果不能,有可能吗?

最佳答案

您可以使用 QLibrary 检查 DLL 是否可用。

加载库后,您将加载您的插件,而不是开始使用 QLibrary::resolve

QLibrary lib("oci"); // QLibrary will try the platform's library suffix
if (! lib.load()) {
qDebug() << "Library load error:" << lib.errorString();
return;
}
// load plugin

您不能使用QPluginLoader 来加载插件,因为您是静态链接,但您应该可以使用QLibrary

manual状态:

Note that the QPluginLoader cannot be used if your application is statically linked against Qt. In this case, you will also have to link to plugins statically. You can use QLibrary if you need to load dynamic libraries in a statically linked application.

关于qt - 在运行时检查 Qt 插件的依赖性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8149242/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com