Wednesday, July 22, 2009

Creating a LIB file for a DLL

I was trying to use a DLL that was supplied with a LIB file that Visual Studio 2008 refused to link to. To get around this I needed to create a new LIB file from the DLL.
Microsoft has instructions to do this (http://support.microsoft.com/kb/131313) but this wasn't working for me. In the end I found the following worked for me.

1. dumpbin /export Filename.dll (do this from a Visual Studio Command prompt)
2. Use the output of dumpbin to produce a file Filename.def (with the functions listed by dumpbin in the EXPORTS section). I found that I needed to edit to remove all leading underscores on the exported functions.
3. lib /def:filename.def
4. This will produce 2 files, filename.lib & filename.exp.
You should now be able to link to this file.

No comments:

Post a Comment