Build Static Libraries

To build a static library, use the following steps:

  1. Prepare your source files
    You can build a library from C sources, C++ sources, object files, or other static libraries. Make sure that you list as sources all files that contain code and data from which you want to build your library.
  2. Specify a .lib as the target of the build
    In your configuration file, make sure the target file for your library has the extension .lib.
  3. Build
    Set build options if you want to override default actions of the compiler, linker or other processes that make up the build. The build process creates your library.

Here is an excerpt from a configuration file. These directives build a library in a file named mylib.lib from three C++ source files and an object file.

   target "mylib.lib" {
      source "a.cpp", "a.hpp", "b.cpp"
      source "c.obj"
   }

When you build a module that links to your library, list the library as a source.

You cannot add or change object modules in a library by specifying the library as both a source and a target of a build.

You can update a library, and perform other maintenance tasks on OS/2 and Windows NT platforms with the library manager, ilib. However, if you change a library with ilib, the utility does not update the codestore and subsequent builds may not have the desired results.

Creating a Static Library with ilib
On OS/2 and Windows NT platforms, you can create a new static library from existing object modules or libraries without performing a full VisualAge C++ build. Use the ilib command:

  1. In the VisualAge C++ command line window, open a working directory.
  2. Issue the ilib command. Use the /out:fileName option to tell ilib to output a 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. You can omit the file extension .obj from the input object files.

For example, the following command creates the library newlib.lib out of objects in abc.obj and mylib.lib. If a library named newlib.lib already exists, it is replaced.

ilib /out:newlib.lib abc.obj mylib.lib


Static and Dynamic Libraries
Configuration Files
Codestore
Maintaining Libraries


Change a Build Setup
Add or Change Source Files
Add or Change Targets
Set Build Options
Build
Build With Existing Object Files and Libraries
Produce Object Files from a Build


Build Options