|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Building an Import Library and Export File
To build an import library and export file, use the following syntax:
LIB /DEF[:deffile] [options] [objfiles] [libraries]
When /DEF is specified, LIB creates the output files from export specifications that are passed in the LIB command. There are three methods for specifying exports, listed in recommended order of use:
A __declspec(dllexport) definition in one of the objfiles or libraries
A specification of /EXPORT:name on the LIB command line
A definition in an EXPORTS statement in a deffile
These are the same methods you use to specify exports when linking an exporting program. A program can use more than one method. You can specify parts of the LIB command (such as multiple objfiles or /EXPORT specifications) in a command file in the LIB command, just as you can in a LINK command.
The following options apply to building an import library and export file:
Note that if you create your import library in a preliminary step, before creating your .dll, you must pass the same set of object files when building the .dll, as you passed when building the import library.