gpt4 book ai didi

c++ - 如何对导出 C++ 类的 DLL 使用延迟加载

转载 作者:可可西里 更新时间:2023-11-01 12:39:55 29 4
gpt4 key购买 nike

我有一个 DLL one.dll,它使用 twoClass 通过 class __declspec(dllexport) 从 two.dll 导出的类。我希望 one.dll/delayload 用于 two.dll,但出现链接错误:

LINK : fatal error LNK1194: cannot delay-load 'two.dll' due to import
of data symbol '"__declspec(dllimport) const TwoClass::`vftable'"
(__imp_??_7TwoClass@@6B@)'; link without /DELAYLOAD:two.dll

这是在发布版本中;在调试版本中它可以工作。 (我不知道 Release 和 Debug 在 vtable 导出方面有什么区别,也找不到任何编译器开关或 pragma 来控制它。)

如何将 /delayload 与在发布版本中导出此类的 DLL 一起使用?

最佳答案

看看 here ,似乎这个人遇到了完全相同的问题并找到了解决方法

I managed to get the delay loading to work in release build by disabling the optimizations on the translation unit that was using SomeClass class - somehow it took away the dependency on exported vtable.

关于c++ - 如何对导出 C++ 类的 DLL 使用延迟加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5232912/

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