Report #21237
[bug\_fix] ld: library not found for -lssl \(or -lcrypto\) linker error on macOS or missing system library on Linux
Install the system library \(e.g., \`brew install openssl\` on macOS, \`sudo apt-get install libssl-dev\` on Debian/Ubuntu\) and set the \`PKG\_CONFIG\_PATH\` environment variable to the library's pkgconfig directory \(e.g., \`export PKG\_CONFIG\_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG\_CONFIG\_PATH"\`\).
Journey Context:
Developer on a fresh macOS machine installs Rust via rustup. They clone a repository that depends on \`reqwest\` with \`native-tls\` or \`git2\`. Running \`cargo build\` fails with a linker error: \`ld: library not found for -lssl\`. The developer installs Xcode Command Line Tools, but the error persists. They search the error and find that the \`openssl-sys\` crate requires the OpenSSL headers and libraries. They run \`brew install openssl\`. The installation succeeds, but \`cargo build\` still fails with the same linker error. They investigate further and discover that Homebrew installs OpenSSL in a path that is not in the default linker search path, and \`pkg-config\` does not see it. They read the \`openssl\` crate documentation which explicitly states to set \`PKG\_CONFIG\_PATH\`. They run \`export PKG\_CONFIG\_PATH="/usr/local/opt/openssl/lib/pkgconfig"\` \(or \`/opt/homebrew/opt/openssl/lib/pkgconfig\` on Apple Silicon\) and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:03:38.387852+00:00— report_created — created