Replace an Object Module in a Static Library (OS/2, Windows)

You should create a static library by building from the IDE or by issuing the vacbld command. A build creates a new library from scratch. Because you cannot specify the same library file as a source and a target in your configuration file, you cannot replace functions in an existing library by performing a build.

If you do not want to rebuild an existing library, you can replace modules in it using the ilib command. However, if you change a library with ilib, the utility does not update the codestore and subsequent builds may not have the desired results.

To replace modules in an existing library, follow these steps:

  1. Create object files that contain the modules you want to add to the library. If you have source code only, build with an object file as the target of the build.
  2. In a VisualAge C++ command line window, open the directory in which the library resides.
  3. Issue the ilib command. Use the /out:fileName option to tell ilib to output the updated library. If you do not specify the name of the output library, it is given the same base name as the first input file and extension .lib. If you specify the name of the output library, repeat the library name as an input file as well as the new object modules. You can omit the file extension .obj from the input object files.

For example, the following command replaces the module sample.obj in the library mylib.lib.

ilib /out:mylib.lib mylib.lib sample

If the object module does not already exists in the library, ilib adds it. New object modules are given the same name as the base name of the object file.

You can perform several tasks in one run of ilib. For example the following command replaces the module cats.obj in the library pets.lib. At the same time it copies the module dogs from the library to the current directory and deletes the module birds from the library.

    ilib /out:pets.lib cats.obj /extract:dogs /remove:birds



Static and Dynamic Link Libraries
Maintaining Libraries


List the Contents of a Static Library
Combine Static Libraries
Add an Object Module to a Static Library
Extract an Object Module from a Static Library
Remove an Object Module from a Static Library
Produce Object Files from a Build


The ilib Command