LIB Commands

The commands field specifies five operations for performing library-management tasks with LIB and manipulating modules: add, delete, replace, copy, and move. These commands can be used on the command line or in a response file in response to the Operations: prompt. To use this field, type a command operator followed immediately by a module name or an object-file name. You can specify more than one operation in this field in any order. If you leave the commands field blank, LIB does not make any changes to oldlibrary.

If you have many operations to perform during a library session, you can use an ampersand (&) to extend the operations line. Type the ampersand after a module name or filename; do not put the ampersand between an operator and a name. Immediately after the ampersand, press ENTER and then continue to type the rest of the command line. You can use this technique on the command line or in response to a prompt. When the ampersand is entered at a prompt, it tells LIB to repeat the Operations: prompt. In a response file, begin a new line of commands after the ampersand. See the examples at the end of this chapter for an illustration of the use of the ampersand.

You can perform one or more library-management functions during a LIB session. For each session, LIB determines whether a new library is being created or an existing library is being examined or modified. It then processes commands in the following order:

1.Deletion and move commands. LIB does not actually delete modules from the existing library file. Instead, it marks the selected modules for deletion, creates a new library file, and copies only the modules not marked for deletion into the new library file. If there are no deletion or move commands, LIB creates the new file by copying the original library file. (The newlibrary field, described on page 706, controls what happens to the existing library.)

2.Addition commands. Like deletions, additions are not performed on the original library file. Instead, the additional modules are appended to the end of the new library file.

As LIB carries out these commands, it reads the object modules in the library and checks them for validity. It then builds a dictionary, an extended dictionary (unless /NOE is specified), and a listing file (if a listfile is specified). The listing file contains a list of all public symbols and the names of the modules in which they are defined.

Important:

Paths and filenames specified with these commands cannot contain a dash character (). LIB interprets the dash as the LIB “delete” operator.

The Add Command (+)

Use the add command to create a library file, to add a module, or to combine libraries. The command has the form:

+name

where name is the name of the object file or library file. If no extension is specified, LIB assumes .OBJ. You can specify a path with the filename.

Creating a New Library

Use the add command to create a new library from one or more object files. Specify the name of the new library in the oldlibrary field, then specify each object file's name preceded by a plus sign. In the following example, LIB is instructed to create the library file FIRST.LIB containing the object module called MORE:

LIB FIRST +MORE;

Adding Library Modules

Use the add command to add an object module to a library. Give the name of the object file to be added immediately following the plus sign. LIB adds object modules to the end of a library file.

LIB strips the drive, path, and extension from the object-file name and leaves only the base name. This becomes the name of the object module in the library. For example, if the object file B:\CURSOR.OBJ is added to a library file, the name of the corresponding object module is CURSOR.

In the following example, LIB is instructed to add the module MORE to the already existing library file FIRST.LIB:

LIB FIRST +MORE;

Combining Libraries

To combine the contents of two libraries, supply the name of a library instead of an object file. In addition to standard libraries, LIB lets you combine import libraries (created by IMPLIB), 286 XENIX archives, and Intel-format libraries.

Specify the plus sign followed by the name of the library whose contents you wish to add to the original library. You must include the .LIB extension of the library name. Otherwise, LIB assumes that the file is an object file and looks for the file with an .OBJ extension.

LIB adds the modules of the new library to the end of the original library. Note that the added library still exists as an independent library. LIB copies the modules without deleting them.

Once you have added the contents of a library or libraries, you can save the new, combined library under a new name by giving a new name in the newlibrary field. If you omit this field, LIB saves the combined library under the name of the original library, that is, the name given in the oldlibrary field. The original library is saved with the same base name and the extension .BAK.

The following example combines DRAW.LIB and CHART.LIB into a library with the filename GRAPHICS.LIB: LIB;commands

LIB DRAW +CHART.LIB, ,GRAPHICS

The Delete Command (-)

Use the delete command to delete an object module from a library. The command has the form:

–name

where name is the name of the module to be deleted. A module name does not have a path or extension; it is simply a name, such as CURSOR.

The following example tells LIB to delete the FLOAT module from the MATH.LIB library:

LIB MATH –FLOAT;

The Replace Command (-+)

Use the replace command to replace a module in the library. The command has the form:

–+name

where name is the name of the module to be replaced. A module name has no path and no extension. LIB deletes the given module and then appends the object file having the same name as the module. The object file is assumed to have an .OBJ extension and to reside in the current directory.

The following three examples of command lines are equivalent. All three instruct LIB to replace the HEAP module in the library LANG.LIB. LIB deletes the HEAP module from the library and then appends the object file HEAP.OBJ as a new module in the library. Delete operations are always carried out before add operations, regardless of the order in which they are specified.

LIB LANG -+HEAP;

LIB LANG -HEAP +HEAP;

LIB LANG +HEAP -HEAP;

The Copy Command (*)

Use the copy command to copy a module from the library file into a newly created object file of the same name. The command has the following form:

*name

where name is the name of the module to be copied. The module remains in the library file. LIB names the object file by using the base name of the module and adding an .OBJ extension. It then puts it in the current directory. You cannot override this filename or location; however, you can later rename the file and copy or move it to any location. LIB writes the full name of the object file (including drive, path to the current directory, base name, and extension) into the header of the object file.

The Move Command (-*)

Use the move command to move an object module from the library file to an object file. The command has the form:

–*name

where name is the name of the module to be moved. This operation is equivalent to copying the module to an object file using the copy command (*) and then deleting the module from the library using the delete command ().