Linking of instrumented code fails with error messages like
error: undefined reference to __cs_tb_16QpRO_1RtJv5_21IXoc_home_someone_src_input_file_cpp
The exact content of the messages depend on the linker, but they
always tell that one or more symbols beginning with
Such errors occur when code that is instrumented by Coco is only linked statically to code that is not instrumented.
When object files are statically linked, the CoverageScanner library, which allocates all tables, is not generated. This library is generated when instrumenting the main application of a dynamic library using the static library.
Possible Causes and Solutions¶
In most of the cases, this issue occurs if:
- static library is not generated with CoverageScanner but with the native toolchain directly.
- or if the main application using the instrumented library is not instrumented.
To fis this issue, it is simply necessary to check that CoverageScnner is used during all linking process (static, dynamic and for the executables).