recently I learning about creating and using DLLs.
I learned that it's very common to declare function as __stdcall.
but then I found a problem that it's hard to link with DLL without lib.
because compiler would like to look for the function name with "@nn" at the end while the lib made from def file not.
so I made a tool to solve the problem.
hoping it helps.
how to use
when got a DLL file with stdcall functions inside, run this tool:
1. using OpenWatcom C: dllstdfix w xx.dll
2. using Microsoft Visual C++: dllstdfix v xx.dll
3. using MinGW GNU C: dllstdfix g xx.dll
4. using Borland C Compile: any of above
to get three files:
then compile xx.dll.asm with YASM or NASM, got xx.dll.obj
nasm -f win32 xx.dll.asm
(if you use borland C Compile, it's not necessary)
then make the import library
1. when using MinGW GNU C Compiler:
dlltool -l xx.a -d xx.dll.def -D xx.dll
ar rs xx.a xx.dll.obj
2. when using Microsoft Visual C++:
lib /def:xx.def /out:xx.tmp.lib
lib xx.lib xx.tmp.lib xx.dll.obj
3. when using OpenWatcom C:
lib386 /def:xx.def /out:xx.tmp.lib
lib386 xx.lib xx.tmp.lib xx.dll.obj
4. when using Borland C Compiler
implib -f xx.lib xx.dll.def
(yes, the obj file is not necessary)
at last, you can link your program with the library. without the problem of
"error LNK2019: unresolved external symbol"
"undefined reference to"
any advice is welcomed.
the tool uses udis86 as disassemble engine.
(to know how many bytes is poped when return)