Translate

segunda-feira, 7 de setembro de 2009

How to create a lib file from a dll?

1-Use impdef.exe to create a def file from a dll. In your shell:

impdef mydef.def mydll.dll

a) If you dont have impdef.exe (comes with Borland instalation and you can get others versions from the Internet), you can too make the def file by yourself, just creating a text file with .def extension and fill it out this way:

LIBRARY MYDLL.DLL

EXPORTS
FUNCTION1 @1 ;FIRST FUNCTION EXPORTED (YOU CAN SEE USING DEPENDENCY WALKER)
FUNCTION2 @2 ;FIRST FUNCTION EXPORTED (YOU CAN SEE USING DEPENDENCY WALKER)
FUNCTION3 @3 ;FIRST FUNCTION EXPORTED (YOU CAN SEE USING DEPENDENCY WALKER)
.
.
.


2-Use lib.exe to generate the lib file:

lib /DEF:C:\Temp\mydef.def /OUT:C:\Temp\mylib.lib


3-Now just add the lib file in your VC project and have fun :)

a) If you have a header file for your dll, you should verify if it has the following struture:

__declspec(dllimport) function1()
__declspec(dllimport) function2()
__declspec(dllimport) function3()

Thats it!

Nenhum comentário: