Report #14501
[bug\_fix] ld: library not found for -lssl \(or -lpq, -lcurl, etc.\) — linker error during cargo build
Install the system development packages containing the static or shared library files and pkg-config metadata. On Debian/Ubuntu: \`sudo apt-get install libssl-dev libpq-dev\`. On Fedora/RHEL: \`sudo dnf install openssl-devel postgresql-devel\`. Ensure \`PKG\_CONFIG\_PATH\` includes the directory containing the \`.pc\` files if installed in non-standard locations, or use the crate's \`vendored\` feature to build from source if available.
Journey Context:
You are setting up a continuous integration pipeline for a Rust web service using \`tokio-postgres\` and \`openssl\` crates. The build fails on the linking step with "ld: cannot find -lpq" even though PostgreSQL client is installed on the runner. You check \`pg\_config --libdir\` and verify the \`.so\` files exist in \`/usr/lib/x86\_64-linux-gnu\`, but the linker still fails. You realize that \`.so\` files are for runtime, but the linker needs the \`.a\` \(static\) files or proper \`-L\` flags with \`.so\` files at link time, which are typically in separate \`-dev\` packages. You install \`libpq-dev\` and \`libssl-dev\`, which provide the necessary \`.pc\` files for \`pkg-config\` to generate correct \`-L\` and \`-l\` flags for the linker. The build succeeds because the system linker can now resolve the symbols for the C libraries that the Rust \`-sys\` crates wrap.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:44:39.773238+00:00— report_created — created