views:

66

answers:

3

I write a program helloworld.exe; it depends on a.dll. I don't have the source code of the a.dll, which is a dynamic dll. How can i change it to static library, so I can link it into helloworld.exe?

+4  A: 

Sorry, but there's no direct way to do so. A DLL is a fully linked executable format file, where a static library is a collection of separate object files collected together. With a little bit of work, you can convert a static library to a DLL, but doing the reverse is non-trivial (to put it mildly).

Jerry Coffin
+1 for the only correct answer to the OP's original question. (My answer is just a workaround)
Billy ONeal
+3  A: 

As Jerry said, you cannot do it directly. You can, however, package your program into something like a self extracting RAR file which includes the DLL as part of the single EXE, which automatically extracts the EXE and associated DLLs to a temp folder and starts the main program.

Billy ONeal
@Billy: +1 a workaround, but a useful one.
Jerry Coffin
A: 

I agree with Jerry, and if it is a deployment problem, you may use Nullsoft Scriptable Install System.

baris_a