简体   繁体   English

Qt5延迟加载opengl32.dll失败

[英]Delay-loading of opengl32.dll fails with Qt5

I need to use OpenGL version 2 features within an Qt5 poject on Windows 7 (Qt is built with desktop OpenGL not ANGLE). 我需要在Windows 7上的Qt5对象中使用OpenGL版本2功能(Qt是使用桌面OpenGL而不是ANGLE构建的)。 To support running the application via remote desktop I would like to fall back to software rendering via Mesa if necessary. 为了支持通过远程桌面运行应用程序,如果需要,我想回到通过Mesa进行软件渲染的方式。 My plan is to check the OpenGl version upon startup. 我的计划是在启动时检查OpenGl版本。 If it is to low, I set a flag in the application settings, print a message and terminate the programm. 如果它是低的,我在应用程序设置中设置一个标志,打印一条消息并终止程序。 When the program is started again I can read the flag and decide if I need to load the opengl32.dll from Mesa instead of Windows' builtin version. 当程序再次启动时,我可以读取标志并确定是否需要从Mesa而非Windows的内置版本加载opengl32.dll。

To get this working I tried delay-loading opengl32.dll by setting the /DELAYLOAD:opengl32.dll linker flag and then using SetDllDierectoryW([path to dir with Mesa's opengl32.dll]) to redirect the dll lookup. 为了使此工作有效,我尝试通过设置/DELAYLOAD:opengl32.dll链接器标志,然后使用SetDllDierectoryW([path to dir with Mesa's opengl32.dll])重定向dll查找,从而延迟加载opengl32.dll。 Unfortunaly this does not work as the builtin version of opengl32.dll is already in memory right after entering main() and thus SetDllDirectory has no effect. 不幸的是,这不起作用,因为输入main()之后,opengl32.dll的内置版本已经在内存中,因此SetDllDirectory不起作用。

Dependency Walker shows me that Qt5Gui.dll itself is linked against opengl32.dll and I suspect that this undermines the delay-loading. Dependency Walker向我展示了Qt5Gui.dll本身与opengl32.dll链接在一起,我怀疑这破坏了延迟加载。 But when I try to also delay-load Qt5Gui.dll the linker fails due to an imported symbol "__declspec(dllimport) public: static struct QMetaObject const QWindow::staticMetaObject" (__imp_?staticMetaObject@QWindow@@2UQMetaObject@@B) . 但是,当我尝试也延迟加载Qt5Gui.dll时,链接器由于导入的符号"__declspec(dllimport) public: static struct QMetaObject const QWindow::staticMetaObject" (__imp_?staticMetaObject@QWindow@@2UQMetaObject@@B) I have how no idea how to get rid of this. 我不知道如何摆脱这一点。

I really need OpenGL 2 so there seems no way around using Mesa for software rendering. 我确实需要OpenGL 2,因此似乎无法使用Mesa进行软件渲染。 But I couldn't come up with an alternative to delay-loading either. 但是我也无法提出延迟加载的替代方法。 Changing the PATH settings whenever I want to switch between hardware and software rendering doesn't seem to work and switching by moving Mesa's opengl32.dll into or out of the application dir is not an option as a normal user shouldn't have the required write permissions. 每当我想在硬件和软件呈现之间切换时似乎都无法更改PATH设置,并且通过将Mesa的opengl32.dll移入或移出应用程序目录来进行切换是不可行的,因为普通用户不应具有必需的写入权限权限。

Is there any way to get delay-loading of opengl32.dll working with Qt5? 有什么办法可以使Qt5延迟加载opengl32.dll?

Qt5Gui itself is linked to OpenGL. Qt5Gui本身已链接到OpenGL。 If your application is able to lazy-load this library, you can try calling QCoreApplication::setLibraryPaths() without system paths, using paths for your libraries instead. 如果您的应用程序能够延迟加载该库,则可以尝试使用不带系统路径的QCoreApplication :: setLibraryPaths()来代替,而应使用库的路径。

Apart from that, your can tweak your qt.conf file. 除此之外,您还可以调整qt.conf文件。 Read about it here: http://qt-project.org/doc/qt-5/qt-conf.html 在这里阅读有关内容: http : //qt-project.org/doc/qt-5/qt-conf.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM