Report #82966
[bug\_fix] Cargo linking error: ld: library not found for -lssl \(or -lcrypto, -lpq, etc.\)
Install the system library and pkg-config \(e.g., 'brew install openssl pkg-config' on macOS, 'apt-get install libssl-dev pkg-config' on Debian\), set environment variables like 'PKG\_CONFIG\_PATH' or 'OPENSSL\_DIR' if the library is in a non-standard location, or enable the 'vendored' feature in the crate \(e.g., 'openssl = \{ version = "0.10", features = \["vendored"\] \}'\) to compile the C library from source during the Rust build.
Journey Context:
Developer adds a dependency like 'reqwest', 'sqlx', or 'openssl' and runs 'cargo build'. The build fails at the linking stage with 'ld: library not found for -lssl' \(on macOS\) or 'cannot find -lssl' \(on Linux\). Developer knows they have OpenSSL installed \(macOS has LibreSSL, Linux has it in /usr/lib\), but the linker can't find it. They try 'export LIBRARY\_PATH=/opt/homebrew/opt/openssl/lib' or similar. They install 'pkg-config' via Homebrew but still get errors. They discover that the 'openssl' crate uses 'pkg-config' to locate the library, but Homebrew's OpenSSL is keg-only and not in the default path. They eventually either set 'PKG\_CONFIG\_PATH=/opt/homebrew/opt/openssl/lib/pkgconfig' or simply enable the 'vendored' feature to avoid system dependencies entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:50:40.513278+00:00— report_created — created