Skip to content
Latchkey

ld "DSO missing from command line" in CI

A symbol is satisfied only by a shared library pulled in indirectly. With --as-needed (the modern default) the linker requires that library to be named explicitly on the link line.

What this error means

An undefined reference is followed by a hint that the defining DSO is missing from the command line, usually for a transitive dependency.

ld
/usr/bin/ld: main.o: undefined reference to 'BZ2_bzBuffToBuffCompress'
/usr/bin/ld: note: 'BZ2_...' is defined in DSO /usr/lib/libbz2.so so try adding it to the linker command line
/usr/bin/ld: libbz2.so: could not read symbols: DSO missing from command line

Common causes

How to fix it

List the library explicitly

  1. Add the named DSO to the link line, after the objects that use it.
  2. In CMake, add it to target_link_libraries for the target.
ld
gcc main.o -o app -lbz2   # name the transitive dependency directly

How to prevent it

  • Link directly against every library whose symbols you use, rather than relying on transitive linkage under --as-needed.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →