Next: the Internals Up: Device Development Previous: Introduction to FDOs, DLLs Contents

## How to create DLLs

If you have already created DLLs once or more, you can probably ignore this chapter.

Otherwise, it isn't so hard either. Everyone of you has probably made a program with more than one object file. The various object files were linked to a single large EXE in the end.

With DLLs, you usually don't have to change a single line of code.

You link one or more object files to a DLL. If other DLLs access to symbols8.2in a DLL, these symbols have to be exported from the DLL which contains them and imported in the DLL which uses these symbols.

The linker does that by itself. You just have to tell it where what symbols can be found.

For this purpose, import libraries exist. They are similar to normal libraries apart from the fact that they don't contain normal code but just links to the DLL. You handle these import libraries like normal libraries (and object files), you just link them to the rest. When the linker needs some function which is described in the library it creates an import (ie a relocation/fixup entry) the target is the corresponding DLL and the corresponding symbol name).

You have to export by EXPs, which are files that contain a list with the to-be-extracted symbols. On linking you pass them to the linker which then creates exports.8.3

EXPs just look like the following to export the function `printf` and the variable `i`.

    'printf_'
    '_i'

You create import libraries by `WLIB x.LIB +x.DLL` presumed that `x.DLL` contains exports.

The main EXE is actually just such a DLL apart from the fact that it doesn't contain any imports but an entry-point to `main_`.

#### Footnotes

... symbols 8.2
  in this case, symbols are variables and functions
... exports.8.3
  An export is just an entry in the entry-table but with a name.

Next: the Internals Up: Device Development Previous: Introduction to FDOs, DLLs Contents