Report #26667
[bug\_fix] ld: library not found for -lssl \(or -lpq, -lcrypto\)
Install the development headers/package for the system library \(e.g., \`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on Fedora, \`brew install openssl\` on macOS with \`export PKG\_CONFIG\_PATH=/opt/homebrew/opt/openssl/lib/pkgconfig\`\), or set the environment variable \`OPENSSL\_DIR\` pointing to the library root. Root cause: \`-sys\` crates \(like \`openssl-sys\`\) use \`pkg-config\` or \`vcpkg\` in their \`build.rs\` to locate native C libraries for linking. If the library binaries/headers are not in system default paths \(e.g., Homebrew's opt path on Apple Silicon\), the linker fails.
Journey Context:
You clone a project using \`reqwest\` with native TLS. You run \`cargo build\`. After compiling hundreds of crates, the build fails at the final link stage with \`ld: library not found for -lssl\`. You are on macOS with Homebrew. You run \`brew install openssl\` and it reports already installed. You build again; same error. You search GitHub issues and find that on Apple Silicon, Homebrew installs to \`/opt/homebrew\`, which is not in the default linker search path. You try \`export OPENSSL\_DIR=/opt/homebrew/opt/openssl\`, but the build still fails. You then find that \`openssl-sys\` uses \`pkg-config\`, so you set \`export PKG\_CONFIG\_PATH="/opt/homebrew/opt/openssl/lib/pkgconfig"\`. The build succeeds. On Ubuntu, you would have needed \`sudo apt-get install libssl-dev\` to get the \`libssl.so\` symlink in \`/usr/lib\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:09:48.548617+00:00— report_created — created