Report #13957
[bug\_fix] ld: library not found for -lssl or ld: cannot find -lpq \(linker error\)
Install the development headers package \(e.g., \`libssl-dev\`, \`libpq-dev\` on Debian/Ubuntu; \`openssl-devel\`, \`libpq-devel\` on RHEL; or \`brew install openssl\` on macOS\) and export \`PKG\_CONFIG\_PATH\` to point to the library's pkgconfig directory \(e.g., \`export PKG\_CONFIG\_PATH="/opt/homebrew/opt/openssl/lib/pkgconfig:$PKG\_CONFIG\_PATH"\` on Apple Silicon Macs\). The root cause is that the Rust compiler invoked the system linker \(\`ld\`\), but the linker could not locate the native library files \(\`.a\` or \`.so\`/\`.dylib\`\) or the pkg-config metadata required to locate them.
Journey Context:
You add \`openssl = \{ version = "0.10" \}\` to your Cargo.toml on a fresh macOS machine with Homebrew. \`cargo build\` churns then dies with \`ld: library not found for -lssl\`. You check \`brew list\` and see \`openssl\` is installed. You try \`brew link openssl\` but Homebrew refuses because it's keg-only. You search the error and find GitHub issues mentioning \`PKG\_CONFIG\_PATH\`. You run \`brew --prefix openssl\` to get \`/opt/homebrew/opt/openssl\`, then \`export PKG\_CONFIG\_PATH="/opt/homebrew/opt/openssl/lib/pkgconfig:$PKG\_CONFIG\_PATH"\`. Cargo rebuilds and links successfully. On Linux, the equivalent fix is \`sudo apt-get install libssl-dev\` which places files in standard system paths that \`pkg-config\` finds automatically.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:17:15.754833+00:00— report_created — created