7

I have a static-linked library which uses some functions from a dll which i need to delay-load. So in my executable's properties i've added this dll under Linker/Input/Delay Loaded DLLs. I can't add this option in the lib itself since it doesn't have the Linker property pages (because it's a static lib)
So now whenever i use this lib in another executable tool i need to add the delay-loading option over and over again, which i want to avoid. I know there used to be a pragma for this

#pragma comment(linker, "/DELAYLOAD:mydll.dll")

However it doesn't work for me because it says

warning LNK4229: invalid directive '/DELAYLOAD:mydll.dll' encountered; ignored

Is there a way out, other than LoadLibrary?

4

1 回答 1

4

对谷歌做了一些研究(像你一样),因为我一直对这些事情感兴趣。明显的链接是:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/807606af-f7d7-4d9b-a9f3-062b23fddb2b/using-the-delayload-linker-switch-with-a-custom-dll

不幸的是,它是从 2004 年开始的,那是 9 年和之前的一些 VS 版本。

但它变得更糟,我还发现了这个:

http://bytes.com/topic/net/answers/280580-delayload-pragma-fixed-whidbey

这晚了一年,听起来很合理:

不,这从来没有可靠地工作过。在 6.0 中允许它是一个错误。我们稍后通过添加警告修复了一个。

罗纳德·莱勒曼斯

Visual C++ 团队

我知道,除了您的三个建议之外,没有其他方法。

于 2013-09-06T14:23:11.853 回答