Jump to content

  • Log In with Google      Sign In   
  • Create Account


#pragma comment(linker,"/delayload:xxx.dll") -- not supported in VS .NET


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 helix   Members   -  Reputation: 301

Like
0Likes
Like

Posted 14 October 2005 - 06:10 AM

The codebase I'm stuck using uses this pragma several times (for directx and other things). Their reasoning is because it will allow the plugin to still load even if you don't have the correct version of directx installed. This way it can be handled by telling the user what the problem is and how to resolve it. [This is something I'd REALLY like to be able to do with my games going forward so I can do away with a separate launcher exe that does this check for me.] So anyway, it appears that it is no longer supported post VS6.0 and after browsing the web for an explaination, it sounds like it never really was guaranteed to work in the first place so they just cut it. This isn't going to be a showstopper for me but it would sure be nice if there was a way to handle it. What can I do to gain this functionality? My project here is to create a plugin dll for another app and if you don't have every single dll installed, it simply won't show up in the plugin list at all currently -- not very elegant. Thanks!

Sponsor:

#2 dalep   Members   -  Reputation: 326

Like
0Likes
Like

Posted 14 October 2005 - 09:21 AM

You'll have to write code that defers runtime linking till later. And that'll probably mean setting up function pointer declarations and using LoadLibrary/GetProcAddress.

(If you don't already know this, LoadLibrary takes a path or filename of a DLL and returns a handle. GetProcAddress takes that handle and the function name and provides you with a pointer to the function. You assign that to a function pointer variable with the correct definition for the function in the DLL and you're good to go. Get it wrong and you'll almost certainly go down in flames)

One way to do this is to wrap those function pointers in another function in your dll (or in a macro) and check the pointer for null. If it is, then you GetProcAddress and hook up etc. At this point you could raise an exception or whatever if LoadLibrary or GetProcAddress return null or there was some other problem you detected. You could also just link everything all at once in whatever context makes the best sense.

If you're talking about dlls with just a handful of exports you want to link, this is no big deal. But for DirectX itself, you've got some fairly heavy lifting to do.

The basic problem is that if you let the OS do this runtime linking for you, it will succeed or fail before execution ever gets to code you have any control over (there may be some way to get your own code in even earlier but I sure don't know what it is)

I've never heard of that pragma before and I don't know what it does. It might set up something like what I described above with those macros.


#3 helix   Members   -  Reputation: 301

Like
0Likes
Like

Posted 14 October 2005 - 11:07 AM

That sounds like a huge pain in the ass and was about what I was expecting. I'll mark that one as "if time". Thanks for the input.

#4 dalep   Members   -  Reputation: 326

Like
0Likes
Like

Posted 14 October 2005 - 12:00 PM

The conversion of function prototypes to function pointer declarations is pretty trivial and can be done with fairly simple text processing. But there's no really slick, easy way to automatically code the hookups - at least none I've come up with before running out of steam on the effort.

#5 trevaaar   Members   -  Reputation: 235

Like
0Likes
Like

Posted 14 October 2005 - 02:38 PM

I'm using Visual C++ .NET 2003 Enterprise Architect, and setting a delay-load DLL worked perfectly fine.

#6 Jan Wassenberg   Members   -  Reputation: 998

Like
0Likes
Like

Posted 15 October 2005 - 01:54 AM

Quote:
The conversion of function prototypes to function pointer declarations is pretty trivial and can be done with fairly simple text processing. But there's no really slick, easy way to automatically code the hookups - at least none I've come up with before running out of steam on the effort.

Here's how:

// glext_funcs.h
FUNC(int, wglSwapIntervalEXT, (int))

// declaring function pointers (this goes in a header)
#define FUNC(ret, name, params) extern ret (CALL_CONV *name) params;
#include "glext_funcs.h"
#undef FUNC

// importing them
// note: can also use GetProcAddress(hDLL, #name)
#define FUNC(ret, name, params) *(void**)&name = SDL_GL_GetProcAddress(#name);
#include "glext_funcs.h"
#undef FUNC


HTH+HAND

#7 helix   Members   -  Reputation: 301

Like
0Likes
Like

Posted 15 October 2005 - 11:20 AM

Thanks Jan, I'll look into that.

Quote:
Original post by trevaaar
I'm using Visual C++ .NET 2003 Enterprise Architect, and setting a delay-load DLL worked perfectly fine.


I assume you're building with the VC7 libs and runtimes? Are you using the pragma as I have in my subject line? I'm wondering how it works for you because I read online that it was specifically taken out of VS .NET.

#8 Arild Fines   Members   -  Reputation: 968

Like
0Likes
Like

Posted 16 October 2005 - 10:03 AM

The /delayload:foo.dll linker command line switch is supported even in the VC++ 2005 beta. Works fine for me.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

#9 helix   Members   -  Reputation: 301

Like
0Likes
Like

Posted 17 October 2005 - 07:13 PM

Quote:
Original post by Arild Fines
The /delayload:foo.dll linker command line switch is supported even in the VC++ 2005 beta. Works fine for me.


So you're not using the pragma but actually putting it in your project settings? Where would I put that? The command line is read only.

Maybe they put the functionality back in for 2005. Does it work for you in 2003?

#10 Arild Fines   Members   -  Reputation: 968

Like
0Likes
Like

Posted 18 October 2005 - 12:55 AM

Quote:
Original post by helix
Quote:
Original post by Arild Fines
The /delayload:foo.dll linker command line switch is supported even in the VC++ 2005 beta. Works fine for me.


So you're not using the pragma but actually putting it in your project settings?

Yes.
Quote:

Where would I put that?

Project Properties->Configuration Properties->Linker->Input->Delay Loaded DLLs
Quote:

The command line is read only.

You don't have a white "Additional options" box there?

Quote:

Maybe they put the functionality back in for 2005. Does it work for you in 2003?

Yes. And in 2002.


--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

#11 helix   Members   -  Reputation: 301

Like
0Likes
Like

Posted 01 November 2005 - 08:12 AM

Wow, I can't believe I didn't notice that line for delay loaded dlls! That appears to work (no more warnings) but I won't know for sure until I'm at a point where I can run this thing.

I did find the additional options edit box...I don't know how I missed it before. :
Thanks




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS