Specify delay loading dll with #pragma in the cpp file
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?
Did some research on google (guess as you) as I am alway interested in such matters. The obviously link is:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/807606af-f7d7-4d9b-a9f3-062b23fddb2b/using-the-delayload-linker-switch-with-a-custom-dll
Unfortunately it is from 2004, that' nine years and some VS versions before.
But it get worser, I found also this:
http://bytes.com/topic/net/answers/280580-delayload-pragma-fixed-whidbey
which is a year late and sounds very plausible:
No, this never worked reliably. It was a bug to allow it in 6.0. One that we fixed later by adding the warning.
Ronald Laeremans
Visual C++ team
I knew, beside your three suggestions no additional, other way.
链接地址: http://www.djcxy.com/p/74128.html上一篇: KO映射问题与子对象