
Chapter 14.
Create files needed to build and use DLLs
dlltool may be used to create the files needed to build and use dynamic link libraries (DLLs).
Warning: dlltool is not always built as part of the binary utilities, since it is only useful for those targets
which support DLLs.
dlltool [-d|--input-def def-file-name]
[-b|--base-file base-file-name]
[-e|--output-exp exports-file-name]
[-z|--output-def def-file-name]
[-l|--output-lib library-file-name]
[--export-all-symbols] [--no-export-all-symbols]
[--exclude-symbols list]
[--no-default-excludes]
[-S|--as path-to-assembler] [-f|--as-flags options]
[-D|--dllname name] [-m|--machine machine]
[-a|--add-indirect] [-U|--add-underscore] [-k|--kill-at]
[-A|--add-stdcall-alias]
[-p|--ext-prefix-alias prefix]
[-x|--no-idata4] [-c|--no-idata5] [-i|--interwork]
[-n|--nodelete] [-t|--temp-prefix prefix]
[-v|--verbose]
[-h|--help] [-V|--version]
[object-file ...]
dlltool reads its inputs, which can come from the -d and -b options as well as object files specified
on the command line. It then processes these inputs and if the -e option has been specified it creates
a exports file. If the -l option has been specified it creates a library file and if the -z option has been
specified it creates a def file. Any or all of the -e, -l and -z options can be present in one invocation
of dlltool.
When creating a DLL, along with the source for the DLL, it is necessary to have three other files.
dlltool can help with the creation of these files.
The first file is a .def file which specifies which functions are exported from the DLL, which func-
tions the DLL imports, and so on. This is a text file and can be created by hand, or dlltool can be
used to create it using the -z option. In this case dlltool will scan the object files specified on its
command line looking for those functions which have been specially marked as being exported and
put entries for them in the .def file it creates.
In order to mark a function as being exported from a DLL, it needs to have an
-export:
name_of_function entry in the .drectve section of the object file. This can be
done in C by using the asm() operator:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
Commenti su questo manuale