Skip to content

Understanding libzmq.so: undefined reference to…@GLIBCXX_3.4.21'

Erik Fröjdh edited this page Apr 19, 2022 · 2 revisions

When compiling the slsDetectorPackage on RH7 (or a similar distribution) with a conda environment activated, and when that environment contains ZeroMQ the linking fails with a bunch of errors like this:

libzmq.so: undefined reference to `VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'

This comes from the fact that the libzmq.so in conda was compiled against a newer version of the C++ standard library than is available on the system. Available ABI versions can be checked with:

strings /usr/lib/libstdc++.so.6 | grep LIBCXX

In short the issue is:

The old system gcc is not compatible with the newer libstdc++ provided by conda

Solutions:

  1. Use the system libzmq. By passing -DZeroMQ_HINT=/usr to cmake at the configure step. This makes cmake look for zmq in /usr and in case it doesn’t find the ZeroMQ.
  2. Load a newer gcc with: module load gcc (or install with conda).
  3. Detect conda/old gcc combination in CMake and choose system libzmq → Complex cmake code and RH7 is on the way out.
  4. Upgrade your Linux distro to a more modern one.

Other solutions that were discussed but discarded:

  1. Default to the system ZeroMQ → If you pulled in ZeroMQ with conda it’s as likely that you want the ZeroMQ from conda
  2. Vendor libzmq in slsDetectorPackage → Longer compile times small mismatches with system library used by other tools?