TLIB.EXE, the Library Manager

From RAD Studio
Jump to: navigation, search

Go Up to Command-Line Utilities Index

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 C++Builder compiler were built with TLIB. You can use TLIB to build your own libraries or to modify the C++Builder 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 BCC32.EXE 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>] 


Command-Line Elements

The following elements can be used in TLIB command lines:

Element Description
<libname>

<libname> is the path name of the library you want to create or manage. The <libname> must be specified.
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 the following general command-line options: /C, /A, /B, /L, /F, /P, /O, /N, /0, and /8 and the following default action options /a, /d, /e, /u, and /x. A default action option specifies an action that is applied for every module that does not have an explicit command specified. Default action options enable you to specify modules in a TLIB command without having to prefix each module with an action symbol.

<operations>

Describes the commands you want TLIB to do with the specified modules. Each command consists of a sequence of one- or two-character operation codes and a file or module name:

<symbol> modulename

If you only want to examine the contents of the library, do not give any commands. For more information, see Operations later in this topic.

@<respfile>

<respfile> is the path and name of the response file you want to include. You can specify more than one response file. For more information, see the Response Files later in this topic.

<listfile>

<listfile> is 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 do not 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.

To display command-line help, enter:

tlib

or

tlib -?

General Command-Line Options

TLIB recognizes the following general command options:

TLIB General Command Options

Option Description

/PSIZE

Sets the library page size to 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 /PSIZE option to increase the page size to 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 /PSIZE with the next available higher page size.

/L

Writes the <listfile> listing file into standard output stdout.

/N

Disables support of command syntax.

/O

Enables support of command syntax.

/0

Purges comment records.

/8

Displays warnings and messages encoded as UTF8.

/F

Forces a new library.

/A

Writes GNU AR format archive with ELF objects.

/B

Instructs tlib to expect a bare response file. See the Bare Response Files section for information.

/C

Sets to use case-sensitive symbols in a library. This option is not normally used.

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

Do not 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 are not 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.


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

TLIB recognizes the following default action options:

TLIB default action options

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


Operations

The <operations> list describes the actions you want TLIB to do with the specified modules 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:

<symbol> modulename

You can put whitespace around either the action symbol <symbol> or the module name modulename, but not in the middle of a two-character action. You can put as many operations as you like on the command line. The order of the operations is not important. TLIB always applies the operations in a specific order:

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

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

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.

Action Symbols

TLIB recognizes three action symbols: *, +, -, which you can use singly or combined in pairs for a total of five distinct operations. The order of 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.

Supported Action Operations

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.


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 command line with options in a response file.
  • Be used with other response files in a single TLIB command line.

Bare Response Files

Unlike a traditional response file, a bare response file does not contain the leading + before any object file nor the trailing & to indicate that another line follows. Bare response files only contain a list of object files, and the /B option is necessary in order to instruct tlib to expect a bare response file.

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:

tlib mylib +x +y +z

Example 2

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

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

Example 3

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

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:

tlib mylib -+x +a -z

Example 5

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

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
  1. 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, type:

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

See Also