Skip to content

Check for undefined symbols at link-time

Laurent Petre requested to merge bugfix/check-for-undefined-symbols into develop


Taken from the commit message:

By default no check for undefined symbols is performed at link-time for
shared libraries. This is a sane default since the environment can be
different at link-time and run-time. However, in our case, the proper
functioning of our system relies only on shared objects. They can be
considered as our binaries.

This commit sets the -Wl,--no-undefined flag if the compiler and
linker support it.

Enabling this new check, triggered an issue with undefined symbols in
the AMC13Manager which missed some dependencies: Boost.System and
uhal::log The missing dependencies have been added to both the build
system and source code.

Related Issue

Fixes #29 (closed).

How Has This Been Tested?

The code still compiles; no change in the output binaries are expected.

Removing the definition of an random function triggers a (more or less) explicit error:

[lpetre@gem904daq04 cmsgemos]$ cmake3 --build _build
[2/2] Linking CXX shared library gemcalibration/
FAILED: gemcalibration/
: && /opt/rh/devtoolset-8/root/usr/bin/c++ -fPIC -DGIT_VERSION=\"e22ed8a\" -DGEMDEVELOPER=\"lpetre\" -flto -fno-fat-lto-objects  -Wl,--no-undefined -shared -Wl,-soname, -o gemcalibration/ gemcalibration/CMakeFiles/gemcalibration.dir/src/version.cpp.o gemcalibration/CMakeFiles/gemcalibration.dir/src/Calibration.cpp.o gemcalibration/CMakeFiles/gemcalibration.dir/src/CalibrationWeb.cpp.o -L/opt/xdaq/lib -Wl,-rpath,/afs/ gembase/ gemutils/ -lxdaq -lxdata /opt/xdaq/lib/ -lxgi -llogudpappender -llogxmlappender -lpeer -lxoap -lconfig -lxcept -ltoolbox /opt/xdaq/lib/ -lpthread /opt/xdaq/lib/libasyncresolv.a /usr/lib64/ /opt/xdaq/lib/ /opt/xdaq/lib/ && :
/tmp/lpetre/cc7yfCFF.ltrans0.ltrans.o: In function `gem::calibration::Calibration::Calibration(xdaq::ApplicationStub*)':
<artificial>:(.text+0x8075): undefined reference to `gem::calibration::Calibration::setCalType(xgi::Input*, xgi::Output*)'
/tmp/lpetre/cc7yfCFF.ltrans0.ltrans.o: In function `gem::calibration::Calibration::Calibration(xdaq::ApplicationStub*)':
<artificial>:(.text+0xb9c6): undefined reference to `gem::calibration::Calibration::setCalType(xgi::Input*, xgi::Output*)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)


  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Merge request reports