Share via


LIB Reference

The Microsoft® 32-Bit Library Manager (LIB) creates and manages a library of Common Object File Format (COFF) object files. LIB can also be used to create export files and import libraries to reference exported definitions.

LIB creates standard libraries, import libraries, and export files that you can use with LINK when building a 32-bit program. LIB runs from a command prompt.

You can use LIB in the following modes:

These modes are mutually exclusive; you can use LIB in only one mode at a time.

LIB Input Files

The input files expected by LIB depend on the mode in which it is being used, as shown in the following table.

Mode Input
Default (building or modifying a library) COFF object (.obj) files, COFF libraries (.lib), 32-bit Object Model Format (OMF) object (.obj) files
Extracting a member with /EXTRACT COFF library (.lib)
Building an export file and import library with /DEF Module-definition (.def) file, COFF object (.obj) files, COFF libraries (.lib), 32-bit OMF object (.obj) files

OMF libraries created by the 16-bit version of LIB cannot be used as input to the 32-bit version of LIB.

LIB Output Files

The output files produced by LIB depend on the mode in which it is being used, as shown in the following table.

Mode Output
Default (building or modifying a library) COFF library (.lib)
Extracting a member with /EXTRACT Object (.obj) file
Building an export file and import library with /DEF Import library (.lib) and export (.exp) file

Other LIB Output

In the default mode, you can use the /LIST option to display information about the resulting library. You can redirect this output to a file.

LIB displays a copyright and version message and echoes command files unless the /NOLOGO option is used.

When you type lib with no other input, LIB displays a usage statement that summarizes its options.

Error and warning messages issued by LIB have the form LNKnnnn. The LINK, DUMPBIN, and EDITBIN tools also use this range of errors. Help for these errors is available by selecting the error in the Output window and pressing F1.

Structure of a Library

A library contains COFF objects. Objects in a library contain functions and data that can be referenced externally by other objects in a program. An object in a library is sometimes referred to as a library member.

You can get additional information about the contents of a library by running the DUMPBIN tool with the /LINKERMEMBER option. For more information about this option, see DUMPBIN Reference.