共用方式為


Managing a Library

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...

This command creates a library from one or more input files. The files can be COFF object files, 32-bit OMF object files, or 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.

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

The following options apply to building and modifying a library:

  • /LIBPATH: dir
    Overrides the environment library path. For details, see the description of the LINK /LIBPATH option.

  • /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.

  • /NAME: filename
    When building an import library, specifies the name of the DLL for which the import library is being built.

  • /NODEFAULTLIB
    Removes one or more default libraries from the list of libraries it searches when resolving external references. See /NODEFAULTLIB for more information.

  • /OUT: filename
    Overrides the default output filename. By default, the output library is created in the current directory, with the base name of the first library or object file on the command line and the extension .lib.

  • /REMOVE: object
    Omits the specified object from the output library. LIB creates an output library by combining all objects (whether in object files or libraries), and then deleting any objects specified with /REMOVE.

  • /SUBSYSTEM:{CONSOLE | EFI_APPLICATION | EFI_BOOT_SERVICE_DRIVER | EFI_ROM | EFI_RUNTIME_DRIVER | NATIVE | POSIX | WINDOWS | WINDOWSCE}[,#[.##]]
    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.

LIB options specified on the command line are not case sensitive.

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

  • To add objects to a library, specify the file name for the existing library and the filenames for the new objects.

  • To combine libraries, specify the library file names. You can add objects and combine libraries with a single LIB command.

  • To replace a library member with a new object, specify the library containing the member object to be replaced and the file name for the new object (or the library that contains it). When an object that has the same name exists in more than one input file, LIB puts the last object specified in the LIB command into the output library. When you replace a library member, be sure to specify the new object or library after the library that contains the old object.

  • To delete a member from a library, use the /REMOVE option. LIB processes any specifications of /REMOVE after combining all input objects, regardless of command-line order.

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 other Microsoft products.

See Also

Reference

LIB Reference