═══ 1. Notices ═══ ═══ 1.1. Copyright ═══ Copyright International Business Machines Corporation, 1992, 1993. All rights reserved. Note to U.S. Government Users - Documentation related to restricted rights - Use, duplication, or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM* Corp. ═══ 1.2. Edition Notice ═══ Second Edition, November 1993. This edition applies to Version 2.01 of IBM* C/C++ Tools (82G3732, 82G3733, 82G3735, 82G3736) and to all subsequent releases and modifications until otherwise indicated in new editions. This publication could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; any such changes will be reported in subsequent revisions. Requests for publications and for technical information about IBM products should be made to your IBM Authorized Dealer or your IBM Marketing Representative. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any ways it believes appropriate without incurring any obligation to you. ═══ 1.3. Special Notices ═══ References in this help to IBM* products, programs, or services do not imply that IBM intends to make these available in all countries in which IBM operates. Any reference to an IBM licensed program in this help is not intended to state or imply that only IBM's licensed program may be used. Any functionally equivalent product, program, or service that does not infringe on any of IBM's intellectual property rights may be used instead of the IBM product, program, or service. Evaluation and verification of operation in conjunction with other products, except those expressly designated by IBM, is the user's responsibility. IBM may have patents or pending patent applications covering subject matter in this help. The furnishing of this help does not give you any license to these patents. The following terms, denoted by an asterisk (*) in this help, are trademarks of the IBM corporation in the United States and/or other countries: C Set ++ C/C++ FirstStep IBM OS/2 Operating System/2 Presentation Manager WorkFrame/2. The following terms, denoted by a double asterisk (**) in this help, are trademarks of the Microsoft Corporation: Microsoft Windows. This help contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. ═══ 2. ------------------------------------------------------------------------------ ═══ ═══ 3. Demangling Compiled C++ Names with CPPFILT ═══ When the IBM* C/C++ Tools compiler compiles a C++ program, it encodes all C++ symbolic names to include type and scoping information. This encoding process is called mangling. The linker uses the mangled names in the object files to resolve external references using the exported names. Tools that use the files with mangled names do not have access to the original source code names, and therefore present the mangled names in their output. Using a process called demangling, the cppfilt utility converts the mangled names to their original source code names so that they can be easily identified. Note: The demangling routines in the runtime library provided with C/C++ Tools offer another method for converting mangled names to their original source code names. You can use these routines to develop tools that manipulate mangled names. For more information on the demangling routines, refer to the appendix on Mapping in the IBM C/C++ Tools: Programming Guide, and the information in the header file. ═══ Exported Names ═══ Exported names are functions and certain other identifiers that are made available to programs that call the DLL in which the names are defined. For more information on how to identify symbolic names for export from a DLL, refer to the chapter on Building Dynamic Link Libraries in the IBM C/C++ Tools: Programming Guide. ═══ 3.1. Using the CPPFILT Utility ═══ The cppfilt utility converts mangled names to demangled names in two separate modes: Text Specify the names of one or more ASCII text files to have the cppfilt substitute demangled names for mangled names wherever it finds them in the text. Input can also be read from stdin. Binary Specify the names of one or more object (.OBJ) and library (.LIB) files to produce demangled output in a format that is suitable for inclusion in a DLL module definition (.DEF) file. All output is sent to stdout. ═══ 3.2. Text mode ═══ Use the cppfilt utility in Text mode when you want to simply substitute demangled names for mangled names wherever they are found in the text. To use the cppfilt utility in text mode, type cppfilt followed by any valid text mode options on the OS/2* command line. The syntax for the cppfilt command in Text mode is: ┌────────────────┐ ──cppfilt───┬────────────┬─┴─── └──/option───┘ ┌────────────────────┐ ────┬────────────────┬─┴─────── └──text-filename─┘ ═══ 3.2.1. Text Mode Options ═══ The cppfilt utility has the following options in Text mode: /C /H or /? /M /Q /S /T /W nnn Note: You can specify options using the slash form (/S) or the dash form (-S). ═══ 3.2.1.1. Class Names ═══ Specify the /C option on the cppfilt command line to instruct the cppfilt utility to demangle stand-alone class names. Stand-alone class names are names that do not appear within the context of a function name or member variable. These names are not normally produced by the compiler. For example, the stand-alone class name Q2_1X1Y would be demangled as X::Y if you specify the /C option. If you do not specify the /C option, the default is not to demangle stand-alone class names. ═══ 3.2.1.2. Help ═══ Specify the /H or /? option on the cppfilt command line to see a short online help on the cppfilt command syntax and options. If you do not specify this option, the default is not to display any online help. ═══ 3.2.1.3. Symbol Map ═══ Specify the /M option on the cppfilt command line to produce a symbol map on standard output. The map contains a list of the mangled names and their corresponding demangled names. This output follows the normal filtered output. If you do not specify the /M option, the default is not to produce a symbol map. ═══ 3.2.1.4. Do Not Display Logo ═══ Specify the /Q option on the cppfilt command line to suppress the display of the logo and copyright notice for the cppfilt utility. If you do not specify this option, the default is to display the logo and copyright notice. ═══ 3.2.1.5. Mangled and Demangled Names Together ═══ Specify the /T option on the cppfilt command line to produce side-by-side demangling. That is, each mangled name is replaced with the demangled name followed by the original mangled name in the text. If you do not specify the /T option, the default is to replace the mangled name by the demangled name only. ═══ 3.2.1.6. Width ═══ Specify the /W width option on the cppfilt command line to have the cppfilt utility print the demangled names in fields width characters wide. If the name is shorter than width, it is padded to the right with blanks; if longer, it is truncated to width characters. If you do not specify the /W width option, the default is not to have a fixed field width when printing demangled names in the text. ═══ 3.2.1.7. Special Symbol Names ═══ Specify the /S option on the cppfilt command line to instruct the cppfilt utility to demangle special compiler-generated symbol names. For example, the compiler-generated symbol name, __ct__3FooFUi, that represents a constructor for the class Foo, would be demangled as Foo::Foo(unsigned int). If you do not specify the /S option, the default is not to demangle special compiler-generated symbol names. ═══ 3.2.2. Text Files ═══ The file you specify for the cppfilt command in text mode should be an ASCII text file that is present in the current directory, unless you specify its path. If you do not specify a text file, the input is read from stdin. ═══ 3.2.3. Output in Text Mode ═══ Output in text mode would be the input text with the mangled names replaced by their demangled names wherever they are found in the text. All output is sent to stdout. ═══ 3.3. Binary Mode ═══ Use the cppfilt utility in Binary mode when you want to demangle names in object (.OBJ) and library (.LIB) files to produce output that is suitable for inclusion in a DLL module definition (.DEF) file. To use the cppfilt utility in Binary mode, type cppfilt /B followed by any valid Binary mode options on the OS/2* command line. The cppfilt utility switches to the Binary mode of operation when it encounters the /B option. The syntax for the cppfilt command in Binary mode is: ┌───────────────┐ ──cppfilt──/B───┬────────────┬┴─ └──/option───┘ ┌────────────────────┐ ────┬──.OBJ-filename─┬─┴──────── └──.LIB-filename─┘ ═══ 3.3.1. Binary Mode Options ═══ The Binary mode of the cppfilt utility has the following options: /H or /? /N /O [ord] /P /Q /R /S /X Note: You can specify options using the slash form (/R) or the dash form (-R). ═══ 3.3.1.1. Operate in Binary Mode ═══ Specify /B on the cppfilt command line to instruct cppfilt to operate in Binary mode. If you do not specify the /B option, cppfilt will operate in the default Text mode. ═══ 3.3.1.2. Exported Symbols ═══ Specify the /X option on the cppfilt command line to include all exported ( EXPDEF ) symbols in the output. If you do not specify the /X option, the default is not to include exported symbols in the output. Note: If you do not specify any of the /X, /R, or /P options, the Binary mode output will include only the library and object names, without any symbol names. ═══ 3.3.1.3. Referenced Symbols ═══ Specify the /R option on the cppfilt command line to include all referenced ( EXTDEF ) symbols in the output. If you do not specify this option, the default is not to include referenced symbols in the output. Note: If you do not specify any of the /X, /R, or /P options, the Binary mode output will include only the library and object names, without any symbol names. ═══ 3.3.1.4. Public Symbols ═══ Specify the /P option on the cppfilt command line to include all public ( PUBDEF, COMDAT, COMDEF ) symbols in the output. Note: Only the first occurrence of a symbol found within the COMDAT sections will be included in the output. Subsequent occurrences of the same COMDAT symbol will appear as comments in the output. If you do not specify this option, the default is not to include public symbols in the output. Note: If you do not specify any of the /X, /R, or /P options, the Binary mode output will include only the library and object names, without any symbol names. ═══ 3.3.1.5. Special Symbol Names ═══ Specify the /S option on the cppfilt command line to instruct the cppfilt utility to demangle special compiler-generated symbol names. For example, the compiler-generated symbol name, __ct__3FooFUi, that represents a constructor for the class Foo, would be demangled as Foo::Foo(unsigned int). If you do not specify the /S option, the default is not to demangle special compiler-generated symbol names. ═══ 3.3.1.6. Ordinals ═══ Specify the /o [ord] option on the cppfilt command line to generate ordinals after each demangled name. If the optional numeric parameter ord is specified, cppfilt will generate the ordinals starting from ord. The ordinals are generated along with the @ character as consistent with the module definition (.DEF) file EXPORTS statement syntax. For example, with the /o 1000 option specified, the output for a single name would look something like this: ;ILinkedSequenceImpl::isConsistent() const isConsistent__19ILinkedSequenceImplCFv @1000 If you do not specify the /o option, the default is not to generate ordinals after each demangled name. For more information on using module definition files, refer to the IBM* OS/2* Developer's Toolkit online Tools Reference for the LINK386 program. ═══ 3.3.1.7. NONAME Keyword ═══ Specify the /n option on the cppfilt command line to instruct cppfilt to generate the NONAME keyword as consistent with the module definition (.DEF) file EXPORTS statement syntax. The NONAME keyword indicates that the exported names should be referenced by their ordinals, and not by their names. Note: You should also specify the /n together with the /o option to generate ordinals. For example, if you specify the /n /o 1000 options, the output for a single name would look something like this: ;ILinkedSequenceImpl::isConsistent() const isConsistent__19ILinkedSequenceImplCFv @1000 NONAME For more information on using module definition files, refer to the IBM* OS/2* Developer's Toolkit online Tools Reference for the LINK386 linker. ═══ 3.3.1.8. Help ═══ ═══ 3.3.1.9. Do Not Display Logo ═══ ═══ 3.3.2. .OBJ and .LIB Files ═══ The filenames that you specify after the cppfilt /B Binary mode command must be object (.OBJ) or library (.LIB) files. They must be present in the current directory, unless their paths are specified. cppfilt will also search for library files along the paths specified in the LIB environment variable if the files are not found in the current directory. Input cannot be read from stdin in Binary mode. You must specify object or library filenames for input. All output is sent to stdout. ═══ 3.3.3. Output in Binary Mode ═══ cppfilt output in Binary mode lists any libraries and any object files within each library. If you specify the /X, /R, and /P options, the exported, referenced, and public symbols are also listed for each object file. For example, the command cppfilt /B /P /O 1000 /N c:\ibmcpp\lib\dde4cc.lib would produce the following output for a library file called DDE4CC.LIB: ;From library: c:\ibmcpp\lib\dde4cc.lib ;From object file: C:\ibmcpp\src\IILNSEQ.C ;PUBDEFs (Symbols available from object file): ;ILinkedSequenceImpl::setToPrevious(ILinkedSequenceImpl::Node*&) const setToPrevious__19ILinkedSequenceImplCFRPQ2_19ILinkedSequenceImpl4Node @1000 NONAME ;ILinkedSequenceImpl::allElementsDo(void*,void*) const allElementsDo__19ILinkedSequenceImplCFPvT1 @1001 NONAME ;ILinkedSequenceImpl::isConsistent() const isConsistent__19ILinkedSequenceImplCFv @1002 NONAME ;ILinkedSequenceImpl::setToNext(ILinkedSequenceImpl::Node*&) const setToNext__19ILinkedSequenceImplCFRPQ2_19ILinkedSequenceImpl4Node @1003 NONAME ;ILinkedSequenceImpl::addAsNext(ILinkedSequenceImpl::Node*,ILinkedSequenceImpl::Node*) addAsNext__19ILinkedSequenceImplFPQ2_19ILinkedSequenceImpl4NodeT1 @1004 NONAME ;From object file: C:\ibmcpp\src\IITBSEQ.C ;PUBDEFs (Symbols available from object file): ;ITabularSequenceImpl::setToPrevious(ITabularSequenceImpl::Cursor&) const setToPrevious__20ITabularSequenceImplCFRQ2_20ITabularSequenceImpl6Cursor @1034 NONAME ;ITabularSequenceImpl::allElementsDo(void*) allElementsDo__20ITabularSequenceImplFPv @1035 NONAME ;ITabularSequenceImpl::removeAll(void*,void*) removeAll__20ITabularSequenceImplFPvT1 @1036 NONAME ;ITabularSequenceImpl::addAllFrom(const ITabularSequenceImpl&) addAllFrom__20ITabularSequenceImplFRC20ITabularSequenceImpl @1037 NONAME ;From object file: IIAVLKSS.C ;PUBDEFs (Symbols available from object file): ;IAvlKeySortedSetImpl::allElementsDo(void*,void*) const allElementsDo__20IAvlKeySortedSetImplCFPvT1 @1080 NONAME ;IAvlKeySortedSetImpl::isFirst(const IAvlKeySortedSetImpl::Node*) const isFirst__20IAvlKeySortedSetImplCFPCQ2_20IAvlKeySortedSetImpl4Node @1081 NONAME ;IAvlKeySortedSetImpl::setToPosition(unsigned long,IAvlKeySortedSetImpl::Node*&) const setToPosition__20IAvlKeySortedSetImplCFUlRPQ2_20IAvlKeySortedSetImpl4Node @1082 NONAME ;IAvlKeySortedSetImpl::locateOrAddElementWithKey(const void*) locateOrAddElementWithKey__20IAvlKeySortedSetImplFPCv @1083 NONAME Note: This is only a partial listing of the actual output. ═══ 4. ------------------------------------------------------------------------------ ═══ ═══ 5. Renaming Dynamic Link Libraries with DLLRNAME ═══ If your application uses the dynamic link libraries (DLLs) provided with C/C++ Tools, you would violate the C/C++ Tools licensing agreement if you shipped your application with the C/C++ Tools library DLLs without first renaming the DLLs. The DLL rename utility, dllrname, allows you to build your application using the library DLLs provided with C/C++ Tools, and then rename the library DLLs so they can be shipped with your application without violating the C/C++ Tools licence agreement. ═══ 5.1. Using the DLLRNAME Utility ═══ To use the DLL rename utility, build your application using the import libraries provided with C/C++ Tools. Then, before you ship your application: 1. Copy the C/C++ Tools DLLs that your application uses into a working directory. 2. Run the DLL rename utility, dllrname, against your executable files and your working copies of the C/C++ Tools DLLs. The utility will rename the DLLs as well as all internal names that need to be changed as a result. ═══ 5.2. Syntax of the DLLRNAME Utility ═══ The syntax for the dllrname command is: ┌────────────────┐ ──dllrname────┬─────────────┬┴── └─Module-name─┘ ┌────────────────────┐ ────┬─────────────────┬┴──────── └─Oldname=Newname─┘ ┌─────────────┐ ────┬─────────┬─┴────────────── └─/Option─┘ ═══ 5.2.1. Module Names ═══ The list of module names includes the C/C++ Tools library DLLs your application uses, along with the EXEs and DLLs that reference them. They must be present in the current directory, unless their paths are specified. Note: It is important that you include all the modules in your application in this list, since the names by which the modules reference the C/C++ Tools library DLLs must also be changed in the modules themselves. ═══ 5.2.2. Name Changes ═══ You specify the list of the name changes to be made by indicating Oldname=Newname on the dllrname command line. Oldname is the name of the C/C++ Tools library DLL as it was shipped from IBM*. Newname is the name under which you will be shipping the C/C++ Tools library DLL with your application. Note: The dllrname utility requires that Oldname and Newname have the same number of characters. For example, to rename the C/C++ Tools library DLL, DDE4SBS.DLL to MYLIBRY.DLL, specify the following on the dllrname command line: DDE4SBS=MYLIBRY ═══ 5.2.3. DLLRNAME Options ═══ The following options control the operation of the dllrname utility: /H or /? /N /Q /R Note: You can specify options using the slash form (/R) or the dash form (-R). ═══ 5.2.3.1. Help ═══ Specify the /H or /? option on the dllrname command line to see a short online help on the dllrname command syntax and options. If you do not specify this option, the default is not to display any online help. ═══ 5.2.3.2. Do Not Rename DLL ═══ Specify the /N option on the dllrname command line to instruct the dllrname utility not to rename any DLLs that appear in both the modules list and the list of name changes. If you do not specify this option, the default is to rename any DLLs that appear in both the modules list and the list of name changes. ═══ 5.2.3.3. Do Not Display Logo ═══ Specify the /Q option on the dllrname command line to suppress the display of the logo and copyright notice for the dllrname utility. If you do not specify this option, the default is to display the logo and copyright notice. ═══ 5.2.3.4. Do Not Generate Report ═══ Specify the /R option on the dllrname command line to suppress the generation of a report detailing the name changes. If you do not specify this option, the default is to generate a report detailing the name changes. ═══ 5.3. An Example ═══ If you compiled your application using the following command lines: ICC /Gd+ /Ge- /FeA.DLL A.C B.C C.C D.C A.DEF IMPLIB A.LIB A.DLL ICC /Gd+ /FeE.EXE E.C F.C G.C H.C A.LIB your application would be made up of the files A.DLL and E.EXE. Since you specified the /Gd+ compile option, your application also requires the file DDE4SBS.DLL from C/C++ Tools. To obtain a renamed copy of DDE4SBS.DLL which you may ship with your application, use the following set of commands: REM Get a working copy of the C/C++ Tools library DLL COPY D:\IBMC\LIB\DDE4SBS.DLL REM Change all the names DLLRNAME A.DLL E.EXE DDE4SBS=MYSBSLB DLLRNAME DDE4BSBS.DLL DDE4SBS=MYSBSLB These commands will change A.DLL and E.EXE so that they will now require MYSBSLB.DLL instead of DDE4SBS.DLL. dllrname will also rename DDE4SBS.DLL to MYSBSLB.DLL. The following is the text of the report generated by the dllrname utility: > DLLRNAME A.DLL E.EXE DDE4SBS.DLL DDE4SBS=MYSBSLB Licensed Materials - Property of IBM IBM C/C++ Tools Version 2.01 - DLL Rename Utility (C) Copyright IBM Corp., 1993, All Rights Reserved US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Processing file A.DLL. 1 external names in file A.DLL have been left unchanged. 2 names found in file A.DLL. Executable name A has been left unchanged. Imported DLL name DDE4SBS has been changed to MYSBSLB. Processing file E.EXE. 2 external names in file E.EXE have been left unchanged. 3 names found in file E.EXE. Executable name e has been left unchanged. Imported DLL name A has been left unchanged. Imported DLL name DDE4SBS has been changed to MYSBSLB. Processing file dde4sbs.dll. 5 external names in file DDE4SBS.DLL have been left unchanged. 6 names found in file DDE4SBS.DLL. Executable name DDE4SBS has been changed to MYSBSLB. Imported DLL name DOSCALLS has been left unchanged. Imported DLL name KBDCALLS has been left unchanged. Imported DLL name VIOCALLS has been left unchanged. Imported DLL name NLS has been left unchanged. Imported DLL name MSG has been left unchanged. File DDE4SBS.DLL has been renamed to MYSBSLB.DLL to match internal DLL name. Complete. 0 error(s) detected. ═══ 5.4. How DLLRNAME Works ═══ All modules (EXEs and DLLs) that use other DLLs contain records specifying a set of external file names that are needed to run the module. The dllrname utility manipulates only these records; it does not modify your executable code. One of the external names specified in a module is the name of the module itself. The name of module, as it appears in its own internal records, is called its internal name. You specify this name with the NAME or LIBRARY record in a DLL module definition (.DEF) file when you link the module. In the case of an .EXE file, the loader essentially ignores the internal name. For a .DLL, its internal name must match its filename otherwise the loader will refuse to load the DLL. By default, dllrname will also change the filename of a DLL if it changed its internal name. The rest of the external names specified in a module are the names of the DLLs to be loaded when the OS/2* loader loads the module. All of these DLLs must be loaded for the OS/2 loader to successfully load the module. If you specify any of these required DLLs for rename on the dllrname command line, dllrname also changes the names of the required DLLs in the module itself. The dllrname utility accepts 16- or 32-bit OS/2 protected mode executables. It will not change DOS or Windows** executables, or any other file with a different format. ═══ 5.5. What DLLRNAME Will Not Do ═══ The dllrname utility will not: o Modify your executable code. This is important to remember if you use the OS/2* API DosLoadModule() or the C/C++ Tools library call _loadmod() to load a required DLL. You must modify your code to load the DLL using its modified name. o Modify DOS or Windows** executables. o Change the name of a DLL to a name of different length. ═══ 5.6. Other Uses for DLLRNAME ═══ The dllrname utility can also be used to: o Rename your own DLLs so that you can have multiple versions of your application resident on the same machine for testing purposes. o Obtain a report that lists all the DLLs used by a module. Simply invoke the dllrname utility without specifying any DLL name changes. ═══ 6. ------------------------------------------------------------------------------ ═══ ═══ 7. Creating and Maintaining Libraries with LIB ═══ The IBM* Library Manager (also referred to as LIB in this reference) lets you create and maintain libraries of object code. Library files are given the extension of .LIB (as in MYLIB.LIB). High Performance File System (HPFS) files with names that end with ".LIB" (as in MYLIBRARYFILE.NEW.LIB) are also supported. LIB works with standard libraries and OS/2* import libraries. It does not work with Dynamic Link Libraries (DLLs). Use the LIB utility to: o Create a new library o Add, delete, or replace modules in a library o Copy object modules in a library to object files o List the contents of a library ═══ 7.1. Running LIB ═══ Run LIB by typing LIB at the operating system prompt. Parameters can be supplied by one of three methods: 1. Enter them directly on the command line. 2. Respond to prompts. 3. Put them in a text file called a response file and specify the file name after the LIB command. To enter more commands than can be conveniently entered on one line, type an ampersand (&) at the end of the line and press Enter to extend the command field to a new line. The ampersand can be used with all three input methods. You can press Ctrl+C or Ctrl+Break at any time during a LIB run to return to the operating system. Interrupting LIB before completion restores the library from the backup. Note: o When started, LIB makes a backup copy of the original library in case it is interrupted or a mistake is made. Make sure you have enough disk space for both your original library and the modified copy. o The library must end with the extension .LIB. If an extension is not specified, the default extension, .LIB, will be appended. HPFS file names are supported. Hence, MYLIBRARYNAME.NEW.LIB is still a valid library. Note that this implies that MYLIBRARYNAME.NEW refers to MYLIBRARYNAME.NEW.LIB. o If you enter an input library name and follow it immediately with a semicolon (;), LIB performs a consistency check on the library and takes no other action. ═══ 7.1.1. Using the Command Line ═══ You can specify all the input LIB needs on the command line. The syntax of the command line is: LIB [options] inlibrary [commands] [[,listfile] [, outlibrary]] [;] inlibrary The input library to be modified. options Options that affect the way LIB runs. commands Commands used to add, delete, replace, copy, and move modules within the library. listfile The name for a listing file. If you don't specify a name, no file is created. outlibrary The output library created from the input library. If you don't specify an output library, your input library is replaced with the modified version (see below). Commas are used to separate commands and options. The semicolon (;) is used to mark the end of the command line. ═══ 7.1.2. Using LIB Prompts ═══ If you don't provide input to LIB on the command line, LIB prompts you for the information it needs by displaying the following messages, one at a time: Prompt Enter Library name Name of the input library to be modified. Operations Commands to modify the library. If no operations are specified, the input library is unchanged. List file Name for a listing file If no listing file is specified, no listing file is created. Output library Name of the output library to be created from the input library. If no output library is specified, LIB modifies the input library. Enter the same information that you would enter when using the LIB command line. Notes o LIB waits for you to respond to each prompt before displaying the next prompt. If you notice that you have entered an incorrect response to a previous prompt, press Ctrl+C or Ctrl+Break to exit LIB and begin again. o A file name must be entered at the Library name: prompt. To choose a default response for any of the other prompts, press Enter. To choose default responses for all remaining prompts, type a semicolon (;) and press Enter. ═══ 7.1.3. Using a LIB Response File ═══ To provide input to LIB with a response file, type: LIB @responsefile; The field responsefile is the name of a file containing the same information that can be specified on the command line. In a sense, a response file extends the command line to include everything in the response file. To split input to LIB between the command line and a response file, put part of your input on the command line and specify a response file (preceding the response file name with the at sign (@)). The response file name can be any valid OS/2* file. To use special characters such as a space or the @ symbol, the filename must be enclosed in quotes. LIB responds to input you place in a response file just as it does to input you enter on a command line or after a prompt. Using a newline character in the response file is the equivalent of pressing the Enter key after a LIB prompt. A response file uses one text line for each prompt. To extend a LIB command to multiple lines, end each line except the last with an ampersand (&). Responses must appear in the same order as the prompts. If a response for one of the prompts does not appear, the default is used. Use a response file for: o Complex and long commands you type frequently o Strings of commands that exceed the limit for command line length. ═══ Specifying LIB Parameters - Examples ═══ This panel shows you examples of each method for specifying parameters to LIB. The operations shown in each example create a new library, NEWLIB.LIB, and its listing file, NEWLIB.LST, from the existing MYLIB.LIB library. MYLIB.LIB is unchanged, but NEWLIB.LIB has these changes: o The contents are case-insensitive. o The module TIM is deleted. o The object file SIMON.OBJ is appended as an object module with the name SIMON. o The existing module KEHM is deleted and is replaced by a new KEHM which is appended after SIMON. o The module LAM is copied into an object file named LAM.OBJ. Command Line Method At the operating system prompt, enter the following two lines. LIB /I MYLIB, SIMON-TIM-+KEHM & *LAM, NEWLIB.LST, NEWLIB; LIB Prompts Method To have LIB prompt you for input, enter LIB with no parameters. Library name: /I MYLIB Operations: +SIMON-TIM-+KEHM & Operations: *LAM List file: NEWLIB.LST Output library: NEWLIB Response File Method First, create a response file with the following contents. /I MYLIB +SIMON-TIM-+KEHM & *LAM NEWLIB.LST NEWLIB Then, assuming the name of the response file is response.fil, invoke LIB with: LIB @RESPONSE.FIL; Note that the lines in the response file match the entries you would have made with the prompting method. Even the ampersand character (&), the continuation character, is used in the same way. ═══ 7.2. Creating a New Library ═══ To create a new library file, specify the name of the library file you want to create on the command line (or at the Library name: prompt when using LIB prompts). Note: A library file is automatically created if the library file name you specify is immediately followed by a command, comma, or semicolon. In this case, the prompt does not appear. If the name you specify for the new library file already exists, LIB assumes that you want to modify the existing file. When you give the name of a file that does not currently exist, LIB displays the following prompt: Library does not exist. Create library? (y or n) Type y to create the file; type n to terminate the LIB run. If you specified an extension other than .LIB, the LIB utility will try to append the .LIB extension to the entire file name. If a library name is not entered, LIB will prompt you for a library name. ═══ 7.3. Modifying a Library ═══ You can use LIB to alter the contents of any object code library. For example, if you work with high level language libraries, you may want to replace a standard routine with your own version of the routine. You may also want to add a new routine to the standard library so that your routine is available along with the standard routines. To modify an existing library file, specify the name of the library file you want to modify on the LIB command line (or at the Library name: prompt when using LIB prompts). In the command field, enter one or more commands to add, delete, or replace modules in the input library. Each command consists of a command character immediately followed by the name of the module or object file. Note that the Add command can be used to combine libraries as well as to add object files to a library. LIB creates a backup file of the library being modified if it already exists. This backup file has the same name as the original library with a .BAK filename extension. Related information: o Add command (+) o Delete command (-) o Replace command (-+) ═══ 7.4. Copying Object Modules to Object Files ═══ To copy a module from a library file to an object file, specify the name of the library file on the LIB command line (or at the Library name: prompt when using LIB prompts). The command field on the command line allows you to move or copy modules. Command Action Copy (*) Copy the module to an object file and retain the module in the library. Move (-*) Copy the module to an object file and delete the module from the library. ═══ 7.5. LIB Listings ═══ Listings give you the exact names of modules and public symbols, allowing you to inspect the contents within a library. To generate a listing file, enter the following on the command line (or at the appropriate LIB prompt): o The name of the library file in the inlibrary field o The name of the listing file in the listfile field When generating a listing file, the amount of detail can be varied. The level of detail is specified with the /Listlevel:n option, with three different levels being available. Level 1 is the default. It is the fastest to generate and contains the least amount of information. All modules are listed in order of occurrence. For each module, the level 1 option: 1. Shows the relative position and size of each module. 2. Lists all the public symbols defined in the module. 3. Lists all external symbols which must be resolved at link time. Level 2 contains all the information of level 1. In addition, for each external symbol, level 2 shows which module in the library contains the required public symbols for resolving at link time. This can be overridden if a module is linked to another module that already contains the symbol. Level 3 contains all the information of level 2. In addition, Level 3 displays the technical characteristics of the library. This option also contains a dump of the extended dictionary. This is useful to determine which modules will be implicitly linked in whenever a particular module is linked in. Note: If you are using the IBM* C/C++ Tools product, definitions with mangled names will be listed with the demangled form in brackets. Sample Cross Reference Listing LIB /LISTLEVEL:2 NEWLIB, NEWLIB.LST; The command above directs LIB to place a listing of the contents of NEWLIB.LIB into the file NEWLIB.LST. No path specification is given for NEWLIB.LST. By default, the file created is put in the current directory. ═══ Listing Example ═══ The syntax for generating a level 3 listing file is: LIB /L:3 NEWLIB, NEWLIB.LST; This command generates the a listing file called NEWLIB.LST containing the following text: IBM (R) Library Manager Version 2.00 Copyright (C) IBM Corporation 1991, 1992. All rights reserved. Library name : D:\TEMP\NEWLIB.LIB Listing detail level : 3 ┌───────────────────────────────────────────────────┐ ┌─┤Number of the module within the parent library. The│ │ │first module number in the listing file is 00000. │ │ └───────────────────────────────────────────────────┘ │ ┌──────────────────────────────────────┐ │ │Name of the module within the library.│ │ └──┬───────────────────────────────────┘   00000:francis(OFFSET:0x00000010, SIZE:0x000004ca):   │ ┌───────────┴─────────────────────────┐ │ │Size (in bytes) of the object module.│ │ └─────────────────────────────────────┘ ┌────────┴───────────────────────────────────────────────────┐ │Relative offset (in bytes) of the module within the library.│ └────────────────────────────────────────────────────────────┘ ┌────────────────────────────────┐ - Public Definitions:─┤Symbols defined by the module. │ francis └────────────────────────────────┘ ┌──────────────────────────────┐ │Symbols defined in a different│ - External Definitions:────┤module within the library. │ DosAllocMem └──────────────────────────────┘ _ilog2 _critlib_except _DosSelToFlat _DosFlatToSel 00001:lam (OFFSET:0x000004e0, SIZE:0x000001d1): - Public Definitions: lam - External Definitions: francis <- 00000:francis────┐ _critlib_except │ _DosSelToFlat ┌───────────────────────────────────┴────────────┐ _DosFlatToSel │Number and name of the module within the library│ │that defines the corresponding public symbol. │ └────────────────────────────────────────────────┘ 00002:hazlett (OFFSET:0x000006c0, SIZE:0x0000021a): - Public Definitions: hazlett - External Definitions: DosFreeMem _critlib_except _DosSelToFlat _DosFlatToSel _pBucketArr 00003:simon (OFFSET:0x000008e0, SIZE:0x00000428): - Public Definitions: simon - External Definitions: _ilog2 hazlett <- 00002:hazlett francis <- 00000:francis _critlib_except _DosSelToFlat _DosFlatToSel _pBucketArr 00004:kehm (OFFSET:0x00000d10, SIZE:0x00000342): - Public Definitions: _kehm - External Definitions: DosFreeMem _critlib_except _DosSelToFlat _DosFlatToSel _pBucketArr The following information describes the characteristics of the library. Page size = 16 The Flags field determines case sensitivity. 0x1 indicates case sensitivity. 0x0 indicates no case sensitivity. Flags = 0x0 Contains extended dictionary Total number of modules = 5 Total bytes for modules = 4592 Total number of symbols in dictionary = 10 Maximum number of symbols in dictionary = 74 Total number of pages for the dictionary = 2 The following is the extended dictionary information. The number in parentheses indicates the number of dependencies. It is followed by the list of modules In this case, modules 0, 2, and 4 have no dependencies, module 1 is dependent on module 0, and module 3 is dependent on modules 0 and 2. ======== Dependencies by Module ======== Module 00000 : (00000) Module 00001 : (00001) 00000 Module 00002 : (00000) Module 00003 : (00002) 00000 00002 Module 00004 : (00000) ═══ 7.6. LIB Commands ═══ LIB commands are used to manipulate modules in a library. A single LIB run can use multiple commands in any order. Each command consists of a one- or two-character command symbol immediately followed by the name of the module or file that is the subject of the command. For example, +EFREM.OBJ adds the EFREM.OBJ object file to a library as EFREM. Command Action [+] Adds an object file or library to a library - Deletes a module from a library -+ Replaces a module in a library * Copies a module from a library to an object file -* Moves a module (copies the module and then deletes it) Notes o If you want to enter more commands than can be conveniently entered on one line, type an ampersand (&) and press Enter at the end of the line. This extends the command field to the next line. o When processing commands, LIB processes all copy commands first. LIB processes the deletions next, and the additions last. o LIB never makes changes to your input library while it runs; it copies the library and makes changes to the copy. However, if you do not specify an output library, LIB overwrites the input library with the modified copy at the end of normal processing. See Using the LIB Command Line for more information. ═══ 7.6.1. Add Command (+) ═══ Use the add command to add an object module or library to a library. The add command is issued by using the plus (+) sign or by leaving a blank space. Adding an Object Module to a Library Type the name of the object file to be added immediately after the plus sign. The .OBJ extension may be omitted. LIB uses the base name of the object file as 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. Object modules are always added to the end of a library file. Combining Two Libraries Specify the name of the library file to be added, including the .LIB extension, immediately after the plus sign (+). A copy of the contents of that library is added to the library file being modified. If both libraries contain a module with the same name, LIB ignores the second module with that name. LIB adds the modules of the library to the end of the library being changed. Note that the added library still exists as an independent library because LIB copies the modules without deleting them. Examples LIB MYLIB +EFREM; The command above adds the file EFREM.OBJ to the library MYLIB.LIB. LIB NEWLIB +KAREN.LIB; The command above adds the contents of the library KAREN.LIB to the library NEWLIB.LIB. The library KAREN.LIB is unchanged after this command is executed. ═══ 7.6.2. Delete Command (-) ═══ Use the delete command (-) to delete an object module from a library. After the minus sign, specify the name of the module to be deleted. Module names do not have path names or extensions. Example LIB MYLIB -EFREM; The command above deletes the module EFREM from the library MYLIB.LIB. ═══ 7.6.3. Replace Command (-+) ═══ Use the replace command (-+) to replace a module in a library. Following the symbol, specify the name of the module to be replaced. To replace a module, LIB performs the following steps: 1. Deletes the existing module 2. Searches the current directory for the .OBJ file with the same file name as the deleted module 3. Appends to the library a copy of the object file with the original module name Example LIB MYLIB -+EFREM; The command above replaces the module EFREM in the MYLIB.LIB library with the contents of EFREM.OBJ from the current directory. The file EFREM.OBJ in the current directory is not altered. ═══ 7.6.4. Copy Command (*) ═══ Use the copy command (*) to copy a module from the library into an object file of the same name. The module remains in the library. When LIB copies the module to an object file, it adds the .OBJ extension to the module name and places the file in the current directory. If a file with this name already exists, LIB overwrites the existing .OBJ file. Example LIB MYLIB *EFREM; The command above copies the module EFREM from the MYLIB.LIB library to a file called EFREM.OBJ in the current directory. The module EFREM in MYLIB.LIB is not altered. ═══ 7.6.5. Move Command (-*) ═══ Use the move command (-*) to copy an object module from the library file to an object file. The object module is then deleted from the library file. This operation is equivalent to copying the module to an object file, then deleting the module from the library. Example LIB MYLIB -*KEELING; The command above moves the module KEELING from the MYLIB.LIB library to a file called KEELING.OBJ in the current directory. Upon completion of this process, MYLIB.LIB no longer contains the module KEELING. ═══ 7.7. Options ═══ Usage Notes: o Option characters are not case sensitive; /H and /h are equivalent. o The characters in brackets can be omitted; /H and /HELP are equivalent. o Unless otherwise specified, most options and commands need only the first letter of their names to be used. The following is a summary of LIB options: Option Action /? or ? or /H[ELP] Display Help /I[GNORECASE] Turn case sensitivity off /NOE[XTDICTIONARY] Disable generation of extended dictionary /NOI[GNORECASE] Turn case sensitivity on /NOL[OGO] Suppress LIB banner /Q[UIET] Suppress LIB banner /P[AGESIZE] Set library page size /L[ISTLEVEL] List current contents of library ═══ 7.7.1. Turn Case Sensitivity Off ═══ Turn Case Sensitivity Off (/I) Syntax: /I[GNORECASE] Purpose: Turns off case sensitivity for symbols By default, case sensitivity is off. Use this option when you are combining a library that was created with case sensitivity on (using the /NOI option) with others that are not case sensitive. The resulting library is not case sensitive. ═══ 7.7.2. Turn Case Sensitivity On ═══ Turn Case Sensitivity On (/NOI) Syntax: /NOI[GNORECASE] Purpose: Turns on case sensitivity By default, case sensitivity is off (/I option). Using this option allows symbols that differ only in case, such as Sine and SINE, to be included as separate symbols in the same library. Note that when you create a library with the /NOI option, LIB marks the library internally to indicate that /NOI is in effect. If you combine multiple libraries, and any one of them is marked /NOI, then the output library is marked /NOI. ═══ 7.7.3. Do Not Generate Extended Dictionary ═══ /NOE Option Disable Generation of Extended Dictionary (/NOE) Syntax: /NOE[XTDICTIONARY] Purpose: Disables generation of extended dictionary The extended dictionary is an optional part of the library that increases linking speed. However, using an extended dictionary requires more memory. The space reserved for the extended dictionary is limited to 64K, no more can be allocated. If LIB reports an out-of-memory error, you may want to use this option. As an alternative, you can split large libraries into smaller libraries to use in linking. ═══ 7.7.4. Set Library Page Size ═══ Set Library Page Size (/P) Syntax: /P[AGESIZE]: n Purpose: Sets library page size This option specifies the library page size of a new library or changes that of an existing library. The new page size n must be an integer value representing a power of 2 between the values 16 and 32,768. A library's page size affects the alignment of modules stored in the library. Modules are always aligned to start at a position that is a multiple of the page size (in bytes) from the beginning of the file. The default page size for a new library is 16 bytes. For an existing library, the default is its current page size. Because of LIB's indexing technique, the larger the page size, the more modules a library can hold. Each module requires an average of n/2 bytes of storage space. Therefore, you should use a small page size unless you need to put a very large number of modules in a library. Another consequence of LIB's indexing technique is that the page size limits the size of the library file to n * 65,536. For example, the option /P:16 limits the size to 1 megabyte (16 * 65,536 bytes). ═══ 7.7.5. Display Help ═══ Display Help Syntax: /H[ELP] or /? or ? Purpose: Displays help on LIB A brief summary of LIB syntax is displayed. ═══ 7.7.6. Supress Banner ═══ Suppress LIB Banner Syntax: /NOL[OGO] or /Q[UIET] Purpose: Suppresses the LIB copyright notice. This option suppresses the banner message when LIB is started. It can be used in batch files. ═══ Library ═══ A library is an organized collection of object code which contains functions and data that are already assembled or compiled. Once an object file is incorporated into a library, it becomes an object module. Libraries are used to: o Support high level languages. Most compilers include libraries to perform standard operations, such as input/output and floating-point mathematics. When your program refers to a library routine, the compiler and linker combine the library routine with your program. o Perform complex and specialized activities, such as database management or advanced graphics. You can use your own libraries or specialized libraries supplied by a vendor. o Support your own work. If you have created routines that you use with a variety of programs, you may want to consolidate these routines into a library. You can then link to one library. ═══ Output Library ═══ If you specify a file in outlibrary, LIB creates a new output file with the modifications and leaves your input file intact. Otherwise, LIB replaces your input file with the modified file. In the latter case, a backup of your original input file is stored in the current directory with the file name extension .BAK. ═══ Object File ═══ An object file is produced by a compiler or assembler from one or more source files. An object file has an extension of .OBJ (as in MYPROJ.OBJ). LIB also supports HPFS file names that end with ".OBJ" (as in MYOBJECTFILE.NEW.OBJ). ═══ Object Module ═══ An object module is a self-contained unit within a library of precompiled or preassembled routines. When individual object files are combined into a single library file, they become object modules. In LIB, an object module is referred to by its name, without a file extension. For example, assume that the object file KEELING.OBJ is inserted into a library. It then becomes an object module and is simply referred to as KEELING. ═══ 8. ------------------------------------------------------------------------------ ═══ ═══ ═══ Trademark of the IBM Corporation ═══ ═══ Dynamic Link Library ═══ ═══ Trademark of the Microsoft Corporation