使用 QMake 时可能会延迟 DLL 加载吗?

发布于 2024-09-07 17:39:18 字数 442 浏览 3 评论 0原文

在我的项目中,我有一组要延迟加载的 DLL,即在第一次使用时而不是在进程启动时加载。 这意味着我想对某些 DLL(不是 Qt 本身)使用 MSVC 链接器的 /DELAYLOAD 标志(更多解释请参阅 [1])。 原因是某些用户在 DLL 初始化期间遇到崩溃(我们无法重现)。 该软件以前的非 Qt 版本没有这个问题,但它使用了延迟加载,因此可能会有所不同。

使用 QMake,我发现没有办法让延迟加载起作用。有谁知道如何使用 qmake 功能绕过 qmake 将 /DELAYLOAD 传递给 msvc 链接器?

[1] http://www.codeproject.com/KB/DLL/Delay_Loading_Dll.aspx< /a>

In my project, I have a set of DLLs I want to load delayed, i.e. on first use instead of on process start.
That means I want to use /DELAYLOAD flag of the MSVC linker (see [1] for more explanation) for certain DLLs (not Qt itself).
The reason is that some users experience crashes during DLL initilization (which we can't reproduce).
A former non-Qt version of the software didn't have that problem, but it used delayed loading, so that might make a difference.

Using QMake, I found no way to get delayed loading to work. Does anyone know how to pass /DELAYLOAD to the msvc linker, using qmake features on bypassing qmake?

[1] http://www.codeproject.com/KB/DLL/Delay_Loading_Dll.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

≈。彩虹 2024-09-14 17:39:18

修改.pro文件:

## Make delayed load possible. If your project is itself a DLL which uses xxx.dll, you
## also need to include this line in the applications that use your DLL.
LIBS += DelayImp.lib

## Specify that xxx.dll loading needs to be delayed
win32:CONFIG(release, debug|release) {
    QMAKE_LFLAGS_RELEASE += /DELAYLOAD:xxx.dll
} else:win32:CONFIG(debug, debug|release) {
    QMAKE_LFLAGS_DEBUG += /DELAYLOAD:xxx.dll
}

我将Qt5.1.1与MSVC 2012一起使用,但根据MS,这应该适用于VC2005及更高版本。

Modify .pro file:

## Make delayed load possible. If your project is itself a DLL which uses xxx.dll, you
## also need to include this line in the applications that use your DLL.
LIBS += DelayImp.lib

## Specify that xxx.dll loading needs to be delayed
win32:CONFIG(release, debug|release) {
    QMAKE_LFLAGS_RELEASE += /DELAYLOAD:xxx.dll
} else:win32:CONFIG(debug, debug|release) {
    QMAKE_LFLAGS_DEBUG += /DELAYLOAD:xxx.dll
}

I use Qt5.1.1 with MSVC 2012, but according to MS this should work from VC2005 and up.

小梨窩很甜 2024-09-14 17:39:18

您应该能够将其添加到 QMAKE_LFLAGS 变量之一,例如 QMAKE_LFLAGS_RELEASE。这将位于负责将 dll 链接到应用程序(可能是创建最终应用程序的文件)的项目文件中。

类似的东西

win32 {
    QMAKE_LFLAGS_RELEASE+=/DELAYLOAD:MyDll.dll
}

应该有效。

You ought to be able to just add it to one of the QMAKE_LFLAGS variables such as QMAKE_LFLAGS_RELEASE. This would be in the project file that is responsible for linking your dll to your application (presumably the one that creates the final application).

Something like

win32 {
    QMAKE_LFLAGS_RELEASE+=/DELAYLOAD:MyDll.dll
}

should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文