LIB Options

The default mode for LIB is to build or modify a library of COFF objects. LIB runs in this mode when you do not specify /EXTRACT (to copy an object to a file) or /DEF (to build an import library).

To build a library from objects and/or libraries, use the following syntax:

LIB [options...] files...

The options that apply to building and modifying a library are listed in the following table:

Option Description
/CONVERT Converts an import library to the previous (Visual C++ version 5.0) format.
/LIBPATH:dir Overrides the environment library path. For more information, see the linker option /LIBPATH.
/LIST Displays information about the output library to standard output. The output can be redirected to a file. You can use /LIST to determine the contents of an existing library without modifying it.
/LINK50COMPAT Generates an import library in the previous (Visual C++ version 5.0) format for backwards compatibility.
/OUT:filename Overrides the default output filename. By default, the output library has the base name of the first library or object on the command line and the extension .LIB.
/REMOVE:object Omits the specified object from the output library. LIB creates an output library by first combining all objects (whether in object files or libraries), then deleting any objects specified with /REMOVE.
/SUBSYSTEM Tells the operating system how to run a program created by linking to the output library. For more information, see the description of the LINK /SUBSYSTEM option in Compiler and Linker Options.

Other LIB options are described in:

The files can be COFF object files, 32-bit OMF object files, and existing COFF libraries. LIB creates one library that contains all objects in the specified files. If an input file is a 32-bit OMF object file, LIB converts it to COFF before building the library. LIB cannot accept a 32-bit OMF object that is in a library created by the 16-bit version of LIB. You must first use the 16-bit LIB to extract the object, then you can use the extracted object file as input to the 32-bit LIB. The 16-bit version of LIB is not provided with Visual Fortran.

By default, LIB names the output file using the base name of the first object or library file and the extension .LIB. If a file already exists with the same name, the output file overwrites the existing file. To preserve an existing library, use the /OUT option to specify a name for the output file.

You can use LIB to perform the following library-management tasks:


Note: You cannot both delete a member and extract it to a file in the same step. You must first extract the member object using /EXTRACT, then run LIB again using /REMOVE. This behavior differs from that of the 16-bit LIB (for OMF libraries) provided in some Microsoft products.