Building an Instrumented Static Library

The build target is not necessarily a complete executable, it can also be a (static) library. Testwell CTC++ can be used to instrument source files of a library.

The instrumentation of the sources takes place normally and then the instrumented objects are put to the library with the library utility. The point to note is that the library will not contain the Testwell CTC++ run-time library. Thus, when you link the instrumented library to your final executable, you have to provide the Testwell CTC++ run-time-library at this stage.

A simple example:
  1. Building the instrumented library
    ctc cl /c file1.cpp
    cl /c file2.cpp
    ctc cl /c file3.cpp
    lib /out:mylib.lib file1.obj file2.obj file3.obj
  2. Building the client program
    cl /Femyprog.exe clnt1.cpp clnt2.cpp clnt3.cpp \
        mylib.lib %CTCHOME%\Lib\ctcwin32.lib

Instrumenting a dynamic library (.dll at Windows, .so at Unix) is done in the same way as instrumenting an executable.