Although the object modules that are produced by MASM or by high-level- language compilers can be linked directly into executable load modules, they can also be collected into special files called object-module libraries. The modules in a library are indexed by name and by the public symbols they contain, so that they can be extracted by the linker to satisfy external references in a program.
The Microsoft Library Manager (LIB) is distributed as the file LIB.EXE. LIB creates and maintains program libraries, adding, updating, and deleting object files as necessary. LIB can also check a library file for internal consistency or print a table of its contents (Figure 4-6).
LIB follows the command conventions of most other Microsoft programming tools. You must supply it with the name of a library file to work on, one or more operations to perform, the name of a listing file or device, and (optionally) the name of the output library. If you do not specify a name for the output library, LIB gives it the same name as the input library and changes the extension of the input library to .BAK.
The LIB operations are simply the names of object files, with a prefix character that specifies the action to be taken:
Prefix Meaning
- Delete an object module from the library.
* Extract a module and place it in a separate .OBJ file.
+ Add an object module or the entire contents of another library
to the library.
You can combine command prefixes. For example, -+ replaces a module, and *- extracts a module into a new file and then deletes it from the library.
_abort............abort _abs..............abs
_access...........access _asctime..........asctime
_atof.............atof _atoi.............atoi
_atol.............atol _bdos.............bdos
_brk..............brk _brkctl...........brkctl
_bsearch..........bsearch _calloc...........calloc
_cgets............cgets _chdir............dir
_chmod............chmod _chsize...........chsize
.
.
.
_exit Offset: 00000010H Code and data size: 44H
__exit
_filbuf Offset: 00000160H Code and data size: BBH
__filbuf
_file Offset: 00000300H Code and data size: CAH
__iob __iob2 __lastiob
.
.
.
Figure 4-6. Extract from the table-of-contents listing produced by the Microsoft Library Manager (LIB) for the Microsoft C library SLIBC.LIB. The first part of the listing is an alphabetic list of all public names declared in all of the modules in the library. Each name is associated with the object module to which it belongs. The second part of the listing is an alphabetic list of the object-module names in the library, each followed by its offset within the library file and the actual size of the module in bytes. The entry for each module is followed by a summary of the public names that are declared within it.
When you invoke LIB with its name alone, it requests the other information it needs interactively, as shown in the following example:
C>LIB <Enter>
Microsoft Ò Library Manager Version 3.08
Copyright Ó Microsoft Corp 1983-1987. All rights reserved.
Library name: SLIBC <Enter>
Operations: +VIDEO <Enter>
List file: SLIBC.LST <Enter>
Output library: SLIBC2 <Enter>
C>
In this example, LIB added the object module VIDEO.OBJ to the library SLIBC.LIB, wrote a library table of contents into the file SLIBC.LST, and named the resulting new library SLIBC2.LIB.
The Library Manager can also be run with a command line of the following form:
LIB library [commands],[list],[newlibrary]
For example, the following command line is equivalent to the preceding interactive session:
C>LIB SLIBC +VIDEO,SLIBC.LST,SLIBC2; <Enter>
As with the other Microsoft utilities, a semicolon at the end of the command line causes LIB to use the default responses for any parameters that are omitted.
Like LINK, LIB can also accept its commands from a response file. The contents of the file are lines of text that correspond exactly to the responses you would give LIB interactively. You specify the name of the response file in the command line with a leading @ character, as follows:
LIB @filename
LIB has only three switches: /I (/IGNORECASE), /N (/NOIGNORECASE), and /PAGESIZE:number. The /IGNORECASE switch is the default. The /NOIGNORECASE switch causes LIB to regard as distinct any symbols that differ only in the case of their component letters. You should place the /PAGESIZE switch, which defines the size of a unit of allocation space for a given library, immediately after the library filename. The library page size is in bytes and must be a power of 2 between 16 and 32,768 (16, 32, 64, and so forth); the default is 16 bytes. Because the index to a library is always a fixed number of pages, setting a larger page size allows you to store more object modules in that library; on the other hand, it will result in more wasted space within the file.