views:

69

answers:

2

Is there a free way to statically link a dll? I've tried dll to lib but $999 is too expensive. What are alternatives since I want to have 1 nice exe instead of 1 exe + 1 DLL.

Thanks

+1  A: 

You could put the dll in your resources and then write it out and load it dynamically. You'll have to use delay-loading and make sure to write it out before you call anything in it.

It's not really linked this way, but you only have to deploy an .exe.

Lou Franco
I'm using Visual Studio, is there a step by step guide for this?
Milo
Not really -- look into reading files out of resources and linking to the dll with delay loading.
Lou Franco
This doesn't work in practice, you won't have write access to the directory on a properly secured machine.
Hans Passant
A: 

I'm not certain it can even be done. There are some issues that would need to be treated very delicately.

  • Resources in the DLL? LIB files wouldn't hold those, so you'd have to export them as well and then reintegrate them into the final EXE
  • Who calls DLLMain, and when?

Lou Franco's idea would skirt all of those issues, but it would be important to make sure you don't leave the unpacked DLLs laying around on your user's drive.

Kennet Belenky