RAD Studio |  |

TLIB.EXE, the Library Manager
Command Line Syntax | TLIB General Command Options | TLIB Default Action Options | TLIB Operations List | Using TLIB Response Files | TLIB Examples
Collapse All

TLIB is a utility that manages libraries of .OBJ (object module) files. A library is a convenient way to deal with a collection of object modules as a unit.

The libraries included with the CodeGear C++ compiler were built with TLIB. You can use TLIB to build your own libraries, or to modify the CodeGear C++ libraries, your libraries, libraries furnished by other programmers, or commercial libraries you've purchased.

When TLIB modifies an existing library, TLIB creates a copy of the original library and gives it a .BAK extension.

You can use TLIB to:

- Create a new library from a group of object modules.
- Add object modules or other libraries to an existing library.
- Remove object modules from an existing library.
- Replace object modules from an existing library.
- Extract object modules from an existing library.
- List the contents of a new or existing library.

TLIB can also create (and include in the library file) an extended dictionary, which can be used to speed up linking.

Although TLIB is not essential for creating executable programs with the CodeGear C++ compiler, it is a useful programming productivity tool that can be indispensable for large development projects.

Command Line Syntax

TLIB <libname> [<options>] [<operations>] [@<respfile>] [, <listfile>]

To display command line help, enter:

tlib

Element | Description
<libname> | The DOS path name of the library you want to create or manage. Every TLIB command must be given a libname. Wildcards are not allowed. TLIB assumes an extension of .LIB if none is given. Use only the .LIB extension because both BCC32 and the IDE require the .LIB extension in order to recognize library files. Note: If the named library does not exist and there are add operations, TLIB creates the library.
<options> | TLIB accepts five general options (C, L, P, O, and 8) as well as five default action options (a, d, e, u, and x). See the headings immediately following this table for details about the TLIB <options> and about the default action options.
<operations> | Describes the actions you want TLIB to do and consists of a sequence of two-character operation codes. If you only want to examine the contents of the library, do not give any operations. For more information, see the heading later in this topic.
@<respfile> | The path and name of the response file you want to include. You can specify more than one response file. For more details, see the heading later in this topic.
<listfile> | The name of the text file that TLIB will produce to hold a listing of the library contents. The listfile name (if given), must be preceded by a comma. No listing is produced if you don't give a file name. The listing is an alphabetical list of each module. The entry for each module contains an alphabetical list of each public symbol defined in that module. The default extension for the listfile is .LST.

TLIB General Command Options

TLIB recognizes five <options>:

- /C (case-sensitive; see further information below)
- /l (produces a listing file on standard output)
- /P (page size; see further information below)
- /0 (zero; purges comment records)
- /8 (displays warnings and messages encoded as UTF8)

TLIB /C Option: Using Case-Sensitive Symbols in a Library

When you add a module to a library, TLIB maintains a dictionary of all public symbols defined in the modules of the library. All symbols in the library must be distinct. If you try to add a module to the library that duplicates a symbol, TLIB displays an error message and doesn't add the module.

Normally, when TLIB checks for duplicate symbols in the library, uppercase and lowercase letters are not treated differently (for example, the symbols lookup and LOOKUP are treated as duplicates). You can use the /C option to add a module to a library that includes symbols differing only in case.

Don't use /C if you plan to use the library with other linkers or let other people use the library.

TLIB normally rejects symbols that differ only in case because some linkers aren't case-sensitive. ILINK32 has no problem distinguishing uppercase and lowercase symbols. As long as you use your library only with ILINK32, you can use the TLIB /C option without any problems.

TLIB /P option: Setting the Page Size to Create a Large Library

The library page size determines the maximum combined size of all object modules in the library, which cannot exceed 65,536 pages. The default (and minimum) page size of 16 bytes allows a library of about 1 MB in size. To create a larger library, use the /P option to increase the page size. The page size must be a power of 2, and it cannot be smaller than 16 or larger than 32,768.

All modules in the library must start on a page boundary. For example, in a library with a page size of 32 (the lowest possible page size higher than the default 16), an average of 16 bytes will be lost per object module in padding. If you attempt to create a library that is too large for the given page size, TLIB will issue an error message and suggest that you use /P with the next available higher page size.

TLIB Default Action Options

The default action options allow you to specify an action or several actions that are used for every subsequent module that does not have an explicit command specified, or until a different action flag is set. Using the default action options enables you to specify modules in a TLIB command without having to prefix each module with a command or action symbol. The TLIB default action options perform actions similar to those performed by the TLIB operation flags described in TLIB Operations List.

TLIB Default Action Options

Symbol | Description
/a | Add the module to the library.
/d | Remove the module from the library.
/e | Extract the module without removing it.
/u | Replace the module in the library.
/x | Extract the module and remove it.

TLIB Operations List

The operation list describes the actions you want TLIB to do and consists of a sequence of operations given one after the other. Each operation consists of a one- or two-character action symbol followed by a file or module name.:

Copy Code

    <symbol> modulename

You can put whitespace around either the action symbol or the file or module name, but not in the middle of a two-character action or in a name. You can put as many operations as you like on the command line, up to DOS's COMMAND.COM-imposed line-length limit of 127 characters. The order of the operations is not important. TLIB always applies the operations in a specific order:

To replace a module, remove it, then add the replacement module.

1. All extract operations are done first.
2. All remove operations are done next.
3. All add operations are done last.

TLIB finds the name of a module by stripping any drive, path, and extension information from the given file name.

Note that TLIB always assumes reasonable defaults. For example, to add a module that has an .OBJ extension from the current directory, you need to supply only the module name, not the path and .OBJ extension.

Wildcards are never allowed in file or module names.

TLIB recognizes three action symbols (*, +, -), which you can use singly or combined in pairs for a total of five distinct operations. The order of the characters is not important for operations that use a pair of characters.

To create a library, you add modules to a library that does not yet exist.

TLIB Action Symbols

Symbol | Name | Description
+ | Add | TLIB adds the named file to the library. If the file has no extension, TLIB assumes an extension of .OBJ. If the file is itself a library (with a .LIB extension), then the operation adds all of the modules in the named library to the target library. If a module being added already exists, TLIB displays a message and does not add the new module.
— | Remove | TLIB removes the named module from the library. If the module does not exist in the library, TLIB displays a message. A remove operation needs only a module name. TLIB lets you enter a full path name with drive and extension included, but ignores everything except the module name.
* | Extract | TLIB creates the named file by copying the corresponding module from the library to the file. If the module does not exist, TLIB displays a message and does not create a file. If the named file already exists, it is overwritten. You can't directly rename modules in a library. To rename a module, extract and remove it, rename the file just created, then add it back into the library.
—* or *— | Extract and remove | TLIB copies the named module from the library to the file. If the module does not exist, TLIB displays a message and does not create a file. If the named file already exists, it is overwritten. TLIB removes the file name and then removes it from the library.
—+ or +— | Replace | TLIB replaces the named module with the corresponding file.

Using TLIB Response Files

A response file is an ASCII text file that contains all or part of a TLIB command. Using TLIB response files, you can build TLIB commands that are longer than one command line. If you need to perform a large number of operations or perform operations several times, response files can make your job easier.

Response files can:

- Contain more than one line of text; use the ampersand character (&) at the end of a line to indicate that another line follows.
- Include a partial list of commands. You can combine options from the the command line with options in a response file.
- Be used with other response files in a single TLIB command line.

TLIB Examples

These simple examples demonstrate some of the different things you can do with TLIB:

Example 1

To create a library named MYLIB.LIB with modules X.OBJ, Y.OBJ, and Z.OBJ, type:

Copy Code

    tlib mylib +x +y +z

Example 2

To create a library named MYLIB.LIB and get a listing in MYLIB.LST too, type:

Copy Code

    tlib mylib +x +y +z, mylib.lst

Example 3

To get a listing in CS.LST of an existing library CS.LIB, type:

Copy Code

    tlib cs, cs.lst

Example 4

To replace module X.OBJ with a new copy, add A.OBJ and delete Z.OBJ from MYLIB.LIB, type:

Copy Code

    tlib mylib -+x +a -z

Example 5

To extract module Y.OBJ from MYLIB.LIB and get a listing in MYLIB.LST, type:

Copy Code

    tlib mylib *y, mylib.lst

Example 6

To create a new library named ALPHA, with modules A.OBJ, B.OBJ, ..., G.OBJ using a response file:

1. First create a text file, ALPHA.RSP, with: +a.obj +b.obj +c.obj & +d.obj +e.obj +f.obj & +g.obj
2. Then use the TLIB command, which produces a listing file named ALPHA.LST: tlib alpha @alpha.rsp, alpha.lst

Example 7

To update modules Y.OBJ and Z.OBJ and delete modules A.OBJ and B.OBJ from MYLIB.LIB:

Copy Code

    tlib mylib /u Y.obj Z.obj /d A.obj B.obj

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!