Linker symbols beginning with "__cs_tb_" are missing

Last edited on

Problem

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 __cs_tb_ are missing.

Explanation

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:

  1. a static library is not generated with CoverageScanner but with the native toolchain directly, or
  2. the main application that uses an instrumented library is itself not instrumented.

To fix this problem, make sure that CoverageScanner is used for every link process — static, dynamic and for the executables.