Thursday, October 8, 2009

Generate .lib from 3rd party DLL without .lib file

1. Open up the Visual Studio Tools command promopt (something like Start -> Program Files -> Microsoft Visual Studio -> Visual Studio Tools -> Visual Studio Command Prompt

2. List down all the function in anydll.dll with following command
dumpbin /exports C:\path\to\anydll.dll

3. Build .def by copy all the function into the anydll.def
the definition must start with EXPORTS
eg.
EXPORTS
anydll_function1
anydll_function2
......

3 Generate the lib file
lib /def:C:\path\to\anydll.def /out:C:\path\to\anydll.lib /machine:x86