Linking with an Import Library
The figure below illustrates a simple case in which you create an application
that uses a single dynamic-link library (.DLL) file.
┌──────────┐ ┌─────────┐ ┌─────────┐ ┌──────────┐
│ .OBJ and │ │.DEF file│ │.LIB file│ │ .OBJ and │
│.LIB files│ │(LIBRARY)│ │(imports)│ │.LIB files│
│ │ │(exports)│ │ │ │ │
└────┬─────┘ └──┬───┬──┘ └──┬───┬──┘ └────┬─────┘
│ │ │ │ │ │
└──────┬─────┘ │ └─────┬─────┘
│ └─(2) IMPLIB─┘ │
(1) LINK386 (3) LINK386
│ │
┌────┴────┐ ┌──────┴──────┐
│.DLL file│ │ .EXE file │
│(library)│ │(application)│
└─────────┘ └─────────────┘
As depicted above, linking occurs in three steps:
- Object files (and dynamic-link libraries) are
linked with a module definition (.DEF) file to create a .DLL file. A .DEF
file is used that defines all functions exported by the .DLL file.
- The IMPLIB program is used to generate an import
library (.LIB) file. IMPLIB takes as input the same module definition
file used in the first step. For each export definition in the .DEF file,
IMPLIB generates a corresponding import definition. (IMPLIB can also use
the .DLL file generated in step 1 if you use the _export keyword in C declarations
to export functions.)
- The .LIB file generated by IMPLIB is used as
input to LINK386, which creates an application (.EXE) file. This .LIB file
provides LINK386 with information about imported dynamic-link functions.
[Back: Linking without an Import Library]
[Next: Module Definition Files Basics]