Separate Linking

With the small example from the basic tutorial, we describe what to do if the compilation command is not used for linking the program.

Assume we would originally build our example program as follows:
cl /c *.c
link /out:prime.exe *.obj
The first line compiles the prime.c, io.c and calc.c to .obj files and the second line links them to prime.exe. We can use wildcard notation, because there are no other .c and .obj files in our directory.
Testwell CTC++ can be used in this context also, as follows:
ctc -i m cl /c *.c	
ctc link /out:prime.exe *.obj
Here the first line instruments and compiles the three .c files to .obj files. No linkage takes place, because the '/c' option is present.

On the second line, ctc is also invoked first. It sees link and based on the Testwell CTC++ configuration settings it knows that link is a command for pure linking. ctc invokes the link command and adds the Testwell CTC++ run-time library as one of the items to be linked. As result, we get the instrumented executable prime.exe.

Note that for ctc link..., there do not need to be any instrumentation options present, because the link command does not compile anything and thus no source file instrumentation takes place.

As a side remark, the above instrumentation, compilation and linking can also be done also as follows:
ctc -i m cl -c *.c
link /out:prime.exe *.obj %CTCHOME%\lib\ctcwin32.lib
The linking is not done by ctc. We have added the Testwell CTC++ runtime library explicitly to the link command, in this example, for 32 bit.