### Produce a Dynamic Link Library

To produce a dynamic link library file as output, compile at least one object file (that does not include the main function) with the /Ge- compiler option, and link it with the /DLL linker option.

You must include an export definition (.exp) file that specifies which functions are to be included in the DLL..

To reduce the size of the DLL and improve its performance, use the following options:

- /ALIGNFILE:value to set the alignment factor in the output file. Set value to smaller factors to reduce the size of the DLL. Larger factors may reduce load time for the DLL.
  By default, the alignment is set to 16.
  By default, the alignment is set to 512.
- /BASE:n to specify the load address. For example, if several DLLs are loaded at base addresses that ensure they do not overlap, the loader does not have to reapply the relocation records.
- /OPTFUNC (once your code is tested and stable) to remove unreachable functions.

For DLLs, setting a /BASE value can save load time when the given load address is available. If the load address is not available, the /BASE value is ignored, and there is no load time benefit.

Once you have produced the DLL, you can produce an executable that links to the DLL. Use the ILIB utility to create an import library, and then use the library file as input when linking a client. When you use an import library, you no longer need to use the IMPORTS statement in a module definition file. The linker determines which functions your object files need during the linking process.

If you do not specify an extension for the output file name, the linker automatically adds the extension .dll to the name you provide. If you do not specify an output filename at all, the linker generates an executable file with the same filename as the first object file it linked.

Dynamic Link Libraries

Linker Output
ILIB Objects