ld "cannot find -lX" in CI
The linker was asked for -lX but found no libX.so or libX.a in any search directory. The development package is missing or the library is in a non-standard path.
What this error means
Linking fails with "cannot find -lfoo", typically because the -dev package is absent on the CI image.
ld
/usr/bin/ld: cannot find -lpng: No such file or directory
collect2: error: ld returned 1 exit statusCommon causes
How to fix it
Install the library or add -L
- Install the development package that ships lib<X>.so.
- Add -L<dir> for libraries in a custom prefix.
ld
apt-get install -y libpng-dev
gcc app.o -o app -L/opt/png/lib -lpngHow to prevent it
- Install all -dev library packages in the runner image and pass -L for any library outside the standard directories.
Related guides
gcc/clang "cannot find -lX" during compile-link in CIFix gcc/clang "cannot find -lX" during a one-step compile-and-link in CI - the named library is not installed…
ld "undefined reference to 'X'" in CIFix ld "undefined reference to 'X'" in CI - the linker found a declaration but no definition, usually a missi…