From: http://hi.baidu.com/oofy/blog/item/fa788a23ebdb4947ad34dede.html
I have never understood these two things. I spent some time today.
Summary:
There are two methods to create a DLL in mingw. One is to use gcc-shared...
The second is to use dllwrap...
Dllwrap is a set of tools called. GCC-shared is directly generated.
Dllwrap is more flexible, but gcc-shared is also enough.
Dlltool is a tool used to generate def, exp, and Lib files.
It can generate exp and Lib files based on the OBJ file (the base function is marked as _ declspec (dllexport) or def file.
The former (exp file, which contains the. edata segment) is used to create the DLL, and the latter (LIB file, which contains the. idata segment) is used to use the DLL
The dllname parameter in dlltool is only used to generate the library language name in the def file and the DLL name in the Lib file.
It does not need DLL information.
Several major references:
Creating a DLL using gcc-shared is also a good foundation for an experiment:
Http://www.adp-gmbh.ch/win/misc/mingw/dll.html
GNU-binutils manual, AS/AR/ranlib/dlltool/LD are all part of it
Gcc-shared parameters:
-- Add-stdcall-alias export symbols with and without @ NN
-- Kill-at remove @ NN from exported symbols
-- Out-implib <File> Generate import library
-- Output-Def <File> Generate a. Def file for the built DLL
Dlltool Parameters
-Z -- output-Def <deffile> name of. Def file to be created.
-- Export-all-Symbols export all symbols to. Def
-- No-export-all-symbols only export listed symbols
-- Exclude-Symbols <list> don't export <list>
-- No-default-excludes clear default exclude symbols
-B -- Base-file <basefile> Read linker generated base file.
-X -- no-idata4 don't generate idata $4 section.
-C -- no-idata5 don't generate idata $5 section.
-U -- add-underscore add underscores to symbols in interface library.
-K -- kill-at kill @ <n> from exported names.
-A -- add-stdcall-alias add aliases without @ <n>.
-P -- ext-Prefix-alias <prefix> Add aliases with <prefix>.
DLL called by _ stdcall generated in msvc and GCC
Http://www.geocities.com/yongweiwu/stdcall.htm
Also, you can experiment with yourself.