How to make import library from DLL(for Visual C++ or MinGW)

Just a note for myself.

How to refine VC++ import library LIB files for DLLs created from Lazarus or MinGW:
  • dumpbin /exports file.dll(dumpbin is included in VC++)
  • Use a text editor to write a def file(e.g. file.def) like the content below:
    EXPORTS
    functiona
    functionb
    functionc
    ……
  • lib /def:file.def to create lib file
  • use the lib file in compilation of application to make the application aware of DLL entry points

To use DLLs from Visual C++ to MinGW, the def files from dumpbin can be compiled into .a files(library files for GCC) with DLLTOOL in MinGW:
  • dlltool -U -d file.def -l file.a
Compatibility note: for compatibility with other compilers and languages(e.g. C++ vs. Pascal), always use stdcall for calling convention and extern “C” in C++ side.

No comments:

Post a Comment

블로그를 이전합니다

뭐, 이런 작은 변방의 블로그에 관심있으신 분들은 아무도 없으시리라 생각합니다만...... (웃음) 블로그 플랫폼을 블로거에서 dev.to로 옮겼습니다. 새 URL은 아래와 같습니다: https://dev.to/teminian 새로운 거처에서 뵙겠습니...

Popular in Code{nested}