Report #17622
[bug\_fix] ld: library not found for -lssl \(linker error\)
Install the native library's development headers using the system package manager \(\`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on Fedora/RHEL, \`openssl\` via Homebrew on macOS\). If the library is in a non-standard path \(e.g., Homebrew on Apple Silicon at \`/opt/homebrew\`\), set the \`PKG\_CONFIG\_PATH\` environment variable \(e.g., \`export PKG\_CONFIG\_PATH="/opt/homebrew/lib/pkgconfig"\`\) or the specific \`LIB\_NAME\_DIR\` variable so the build script can locate the library.
Journey Context:
Developer adds a crate like \`openssl\` or \`reqwest\` with native-tls to their project. It compiles successfully on their local macOS machine where OpenSSL is installed via Homebrew. They push to CI \(GitHub Actions using Ubuntu\), and the build fails at the final linking stage with \`ld: cannot find -lssl\`. On macOS, if Homebrew is on Apple Silicon, it installs to \`/opt/homebrew\`, which is not in the default linker search path, causing the same error. Developer learns that \`-sys\` crates \(like \`openssl-sys\`\) contain build scripts that invoke the system linker. The linker needs the actual \`libssl.a\` or \`libssl.so\` files. The developer installs \`libssl-dev\` on Debian or \`openssl-devel\` on Fedora. On macOS M1/M2, they must additionally run \`export PKG\_CONFIG\_PATH="/opt/homebrew/lib/pkgconfig"\` or \`export OPENSSL\_DIR=/opt/homebrew/opt/openssl\` so the build script can generate the correct \`-L\` flag for the linker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:52:49.544717+00:00— report_created — created