Report #68837
[bug\_fix] Linker error: ld: cannot find -lssl: No such file or directory
Install the OpenSSL development headers and libraries \(e.g., \`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on Fedora\), then ensure \`PKG\_CONFIG\_PATH\` includes the directory containing \`openssl.pc\` \(e.g., \`export PKG\_CONFIG\_PATH=/usr/local/opt/openssl/lib/pkgconfig:$PKG\_CONFIG\_PATH\` on macOS with Homebrew\). Root cause: The \`openssl-sys\` crate uses \`pkg-config\` in its \`build.rs\` to locate the native library; if the \`.pc\` file is missing or points to non-existent libraries, the linker receives \`-lssl\` without a valid search path, causing the link failure.
Journey Context:
Developer adds \`reqwest = \{ version = "0.11", features = \["native-tls"\] \}\` to \`Cargo.toml\` on a fresh macOS machine. \`cargo build\` compiles all Rust dependencies but fails at the final linking stage with \`ld: library not found for -lssl\`. Developer realizes this is a system library issue, not a Rust code issue. They install OpenSSL via \`brew install openssl\`, but the error persists. Checking \`openssl-sys\` documentation, they discover it relies on \`pkg-config\` to locate libraries. Running \`pkg-config --libs openssl\` returns nothing or points to the wrong location. They manually set \`export OPENSSL\_DIR=/usr/local/opt/openssl\` but still get linker errors. Finally, they set \`export PKG\_CONFIG\_PATH=/usr/local/opt/openssl/lib/pkgconfig:$PKG\_CONFIG\_PATH\`, allowing \`pkg-config\` to find \`openssl.pc\`, which provides the correct \`-L\` flag to the linker. The build succeeds. On Linux, the same error requires installing \`libssl-dev\` so that \`libssl.so\` exists in \`/usr/lib\`, which \`pkg-config\` locates automatically.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:01:41.489985+00:00— report_created — created