Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Lib

Tool

SYNTAX

Lib objectFile1 [objectFile2]… [-d] [-df deleteFile]
[-dm name[,name]…] [-dn name[,name]…] [-dnx name[,name]…] [-f]
[-mf] [-o name.o] [-p] [-rn oldName=newName[,oldName1=newName2] …]
[-sg newSeg=oldSeg1[,oldSeg2…]…] [-sn oldSeg=newSeg]
[-sym [on|full[,nolines][,nolabels][,novars][,notypes]] | off]
[-w] [-ver number]

DESCRIPTION

The Lib tool combines several object files into a larger object file called a library. This library can then be put into the makefile of a program, significantly reducing link time. In effect, you are precompiling sections of your code--optimally ones that do not change much--and combining them into a large file that can be used by any number of programs.

Building a library allows you to

use the library in several programs without having to recompile the code each time

combine object code written in different languages into a single file

combine several libraries into a single library (for a particular application or desk accessory, for instance), which also improves linker performance

customize a library by deleting unneeded modules (-dm), changing segmentation (-sg and -sn), and changing variables from global to local (-dn and -dnx)

Note that the linker's output is the same size whether or not a library is used in the makefile. Although multiple symbols are reduced to a single symbol, modules are not combined into larger modules and cross-module references are not resolved. Lib can be used to create a CFM-68K static runtime library. There is no -model cfmseg option supported by Lib since it determines the output library type from the type of input files.

INPUT

One or more object files. The Lib tool does not read standard input. All object files must have been compiled for the same runtime model. You cannot mix object files compiled for classic 68K with files compiled for CFM-68K on the command line.

OUTPUT

Output is placed in the data fork of the library file, Lib.Out.o. You can use the -o option to rename this file. Normally the library is given a file of type 'OBJ ' and a creator of 'MPS '.

Note
If an error or user interrupt causes the output file to be invalid, the Lib tool sets the modification date on the file to 0 (that is, January 1, 1904, 12:00 A.M.). This guarantees that the Make tool recognizes that the library needs to be rebuilt. •

STATUS

Lib can return the following status codes:

0

no errors

1

syntax error

2

fatal error

PARAMETERS

objectFile1 [objectFile2]…

Specifies one or more object files of type 'OBJ '.

OPTIONS

-d

Suppresses warnings for duplicate symbol definitions for both data and code.

-df deleteFile

Deletes the list of external modules found in deleteFile.

-dm name[,name]…

Deletes the specified entry points or external modules from the output file. This option allows you to make the library file smaller, reducing subsequent link time.

When you delete an entry point, Lib deletes only that entry point, not the module or any other entry point in that module. If you delete a module, all of its associated entry points are also deleted.

Note
Deleted modules or entry points that are referenced from active code must be resolved by external modules or entry points in another file. •

-dn name[,name]…

Deletes one or more entry-point or module names from the output file by reducing their scope to local. This is a gentle deletion in that the contents of the entry points and modules remain present in the output file. References to names deleted in this way continue to refer to the same code, but with a local scope.

This option is particularly useful when a global name conflict occurs between two pieces of code, one of which is library code from which you do not need to call the name directly.

-dnx name[,name]…

Lets you specify a list of entry-point or module names you want to keep and deletes the rest of the names from the output file by reducing their scope to local. This is a gentle deletion in that the contents of the entry points and modules remain present in the output file. References to names deleted in this way point to the same code but with a local scope.

-f

Treats duplicate data definitions as Fortran "common" regions (multiple data modules with the same name). The size of the largest module is used. There can be at most one initialization of the data.

-mf

Enables the use of Process Manager temporary memory. Note that the Lib command's use of Process Manager temporary memory excludes other applications from using it, including the Finder.

WARNING
If Lib aborts abnormally, that is, there is a crash or a nonmaskable interrupt (NMI), much of the Process Manager temporary memory might be left permanently allocated, thus potentially crippling launches and Finder copy operations. The only way to recover from this situation is to restart the computer. •

-o name.o

Renames the output file to name.o. The default name is Lib.Out.o.

-p

Writes progress and summary information to diagnostic output.

-rn oldName=newName[,oldName1=newName2]…

Changes module name from oldName to newName.

Note
You should not use this option with object files compiled for the CFM-68K runtime environment. •

-sg newSeg=[oldSeg1[,oldSeg2]…]…

Changes segmentation so that code in the old segments (oldSeg1, oldSeg2,…) is placed in the segment newSeg. If you do not specify the old segments, the Lib tool places all code in newSeg.

-sn oldSeg=newSeg

Changes a segment name so that the code in the old segment is placed in the segment named newSeg.

-sym [on | full[,nolines][,nolabels][,novars][,notypes]] | off

Determines whether to keep or discard the symbolic debugging information. Note that the parameters on and full are equivalent.

on | full

Keeps the complete object file records with symbolic debugger information (the default). You can limit-sym on by also specifying one or more of the following parameters:

,nolines

Discards line information.

,nolabels

Discards label information.

,novars

Discards variable information.

,notypes

Discards type information.

off

Does not generate object file records containing symbolic information.

-w

Suppresses warning messages.

-ver number

Sets the version of the OMF file to number.

EXAMPLES

The following command line combines all the libraries (≈) in the {CLibraries} directory into a single library named CLibrary.o.

Lib "{CLibraries}"≈ -o "{CLibraries}"CLibrary.o

For applications that require most or all of the C library files, using the combined C library file reduces link time.

LIMITATIONS

When Lib is processing library files, the maximum number of objects (symbols, modules, labels) that it can store is 16 MB. Each object file may contribute up to 64 KB toward this maximum. The limit on the number of symbols in an output file is set at 64 KB.

SEE ALSO

DumpObj

ILink

SC[pp]

 
 


Last Updated July 2000