Report #72025
[bug\_fix] Linker error: ld: library not found for -lssl \(OpenSSL\)
Install the OpenSSL development packages for your platform: \`sudo apt-get install libssl-dev pkg-config\` on Debian/Ubuntu, \`brew install openssl\` and potentially \`export OPENSSL\_DIR=$\(brew --prefix openssl\)\` on macOS, or \`dnf install openssl-devel\` on Fedora. Alternatively, enable the \`vendored\` feature on the \`openssl\` crate to build from source.
Journey Context:
I cloned a Rust web service repository onto a fresh macOS machine and ran \`cargo build\`. The compilation proceeded until the linking stage, where it failed with \`ld: library not found for -lssl\`. The error originated from the \`openssl-sys\` crate, which was being built as a dependency of \`reqwest\`. I initially tried installing OpenSSL via \`brew install openssl\`, but the error persisted. I realized that on macOS, Homebrew installs OpenSSL in a non-standard path \(\`/opt/homebrew/opt/openssl@3\` on Apple Silicon\) that the linker does not search by default. The \`openssl-sys\` build script uses \`pkg-config\` to locate libraries. I needed to either set \`export OPENSSL\_DIR=$\(brew --prefix openssl\)\` to point the build script to the correct location, or install \`pkg-config\` \(\`brew install pkg-config\`\) so the \`.pc\` files in the Homebrew path could be found. On Linux CI runners, the equivalent fix is \`apt-get install libssl-dev pkg-config\`. The fix works because the \`openssl-sys\` crate relies on the system's C linker \(\`ld\`\) to find and link against the native OpenSSL libraries at build time; without the development headers and static libraries, the linker cannot satisfy the \`-lssl\` flag.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:28:44.507758+00:00— report_created — created