Tracker library reference
When a Tcl Program is instrumented, it needs a "tracker library", libcoveragescannertcl, to count the number of times the code is executed and later write the .csexe file. This library must be compiled by the user because it needs the same Tcl version as the instrumented program.
Compilation of the tracker library
Linux
The source code of the tracker library is in the subdirectory tclcoverage/src of the Coco installation. With the standard installation, this is the directory /opt/SquishCoco/tclcoverage/src.
- Before compiling the library, find out where the include directory and the library file of your Tcl installation are.
- The include directory is the directory in which the file
tcl.his. On a Linux system, it could be/usr/include/tcl8.6. - The Tcl library file must have a
.asuffix, for example/usr/lib/x86_64-linux-gnu/libtcl8.6.a
- The include directory is the directory in which the file
- Create a build directory for
libcoveragescannertcl. From the build directory, run CMake with the following parameters:- an option
-Dto set the CMake variableTCL_INCLUDE_PATHto your Tcl include directory, - an option
-Dto set the CMake variableTCL_LIBRARYto your Tcl library file, and - the path to the Sources of the Coco Tcl library.
The resulting CMake call could therefore be
cmake -DTCL_INCLUDE_PATH=/usr/include/tcl8.6 -DTCL_LIBRARY=/usr/lib/x86_64-linux-gnu/libtcl8.6.a /opt/SquishCoco/tclcoverage/src
- an option
- Compile the tracker library. The result will be a file
libcoveragescannertcldll.soin the build directory.
macOS
The source code of the tracker library is in the subdirectory tclcoverage/src of the Coco installation. With the standard installation, this is the directory /Applications/SquishCoco/tclcoverage/src.
- Before compiling the library, find out where the include directory and the library file of your Tcl installation are.
- The include directory is the directory in which the file
tcl.his. On a macOS system, it could be/opt/homebrew/include. - The Tcl library file must have a
.dylibsuffix, for example/opt/homebrew/lib/libtcl8.6.dylib
- The include directory is the directory in which the file
- Create a build directory for
libcoveragescannertcl. From the build directory, run CMake with the following parameters:- an option
-Dto set the CMake variableTCL_INCLUDE_PATHto your Tcl include directory, - an option
-Dto set the CMake variableTCL_LIBRARYto your Tcl library file, and - the path to the Sources of the Coco Tcl library.
The resulting CMake call could therefore be
cmake -DTCL_INCLUDE_PATH=/opt/homebrew/include -DTCL_LIBRARY=/opt/homebrew/lib/libtcl8.6.dylib /Applications/SquishCoco/tclcoverage/src
- an option
- Compile the tracker library. The result will be a file
libcoveragescannertcldll.dylibin the build directory.
Windows
The source code of the tracker library is in the subdirectory tclcoverage\src of the Coco installation. With the standard installation, this could be the directory C:\Program Files\squishcoco\tclcoverage\src.
- Before compiling the library, find out where the include directory and the library file of your Tcl installation are.
- The include directory is the directory in which the file
tcl.his. On a Windows system, it could beC:\tcl8.6\x64\include. - The Tcl library file must have a
.libsuffix, for exampleC:\tcl8.6\x64\lib\tcl86t.lib
- The include directory is the directory in which the file
- Create a build directory for
libcoveragescannertcl. From the build directory, run CMake with the following parameters:- an option
-Dto set the CMake variableTCL_INCLUDE_PATHto your Tcl include directory, - an option
-Dto set the CMake variableTCL_LIBRARYto your Tcl library file, and - the path to the Sources of the Coco Tcl library.
The resulting CMake call could therefore be
cmake -DTCL_INCLUDE_PATH=C:\tcl8.6\x64\include -DTCL_LIBRARY=C:\tcl8.6\x64\lib\tcl86t.lib "C:\Program Files\squishcoco\tclcoverage\src"
- an option
- Compile the tracker library with
cmake --build .
The result will be a file
Debug\coveragescannertcldll.dllin the build directory.
Use of the tracker library
After the Tcl code is instrumented, it needs the tracker library in order to run. To find it, one must set the environment variable COCOTCLTRACKERDLL to the path to the tracker library.
Under Linux, this could look like this:
$ export COCOTCLTRACKERDLL=/home/user/tclbuild/libcoveragescannertcldll.so $ tclsh tcalc.tcl
Under macOS, it could be:
$ export COCOTCLTRACKERDLL=/home/user/tclbuild/libcoveragescannertcldll.dylib $ tclsh tcalc.tcl
while under Windows, it could be
C:\workdir>set COCOTCLTRACKERDLL=C:\home\user\tclbuild\coveragescannertcldll.dll C:\workdir>tclsh tcalc.tcl
When the instrumented program finishes, it writes its measurements to a file tclcoverage.csexe in its work directory. The files tclcoverage.csmes and tclcoverage.csexe can then be read and processed with the usual Coco tools.
Coco v7.4.0 ©2025 The Qt Company Ltd.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.