windowsvisual-c++dll

How to generate an import library (LIB-file) from a DLL?


Is it possible to autogenerate a MSVC import library (LIB-file) from a DLL? How?


Solution

  • You can generate a DEF file using dumpbin /exports:

    echo LIBRARY SQLITE3 > sqlite3.def
    echo EXPORTS >> sqlite3.def
    for /f "skip=19 tokens=4" %A in ('dumpbin /exports sqlite3.dll') do echo %A >> sqlite3.def
    

    The librarian can use this DEF file to generate the LIB:

    lib /def:sqlite3.def /out:sqlite3.lib /machine:x86
    

    All of the filenames (sqlite3.dll, sqlite3.def, etc.) should be prepended with full paths.