Report #41347
[bug\_fix] linker error ld: cannot find -lssl when building crate with OpenSSL dependency
Install the OpenSSL development packages for your platform \(e.g., \`sudo apt-get install libssl-dev pkg-config\` on Debian/Ubuntu, \`sudo dnf install openssl-devel pkgconf\` on Fedora\) and ensure \`pkg-config\` is installed so the build script can locate the libraries
Journey Context:
Developer pulls a Rust project using \`reqwest\` or \`native-tls\` in a fresh Docker container or CI runner. They run \`cargo build\` and after compiling dependencies, the linker fails with "ld: cannot find -lssl" and "ld: cannot find -lcrypto". Developer first tries installing \`openssl\` via \`apt-get install openssl\`, but the error persists because that only installs the runtime binaries, not the headers and static libraries needed for linking. They search online and find suggestions to set \`LIBRARY\_PATH\` or \`LD\_LIBRARY\_PATH\`, which they try unsuccessfully. They discover that the \`openssl-sys\` crate uses \`pkg-config\` to locate libraries, but \`pkg-config\` isn't installed in the minimal container. After installing \`pkg-config\` and \`libssl-dev\`, the build succeeds. The root cause insight is that Cargo invokes the system linker \(\`cc\`/\`ld\`\), which requires development headers \(\`.h\` files\) and library archives \(\`.a\` or \`.so\` files\) to link against C libraries, and the discovery mechanism relies on \`pkg-config\` files \(\`.pc\`\) that ship with \`-dev\` packages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:52:25.151402+00:00— report_created — created