Report #74251
[bug\_fix] ld: cannot find -lssl \(or -lcrypto, -lpq, etc.\)
Install the missing system development headers for the native library. On Debian/Ubuntu: \`sudo apt-get install libssl-dev\`. On Fedora/RHEL: \`sudo dnf install openssl-devel\`. On macOS: install Xcode Command Line Tools or \`brew install openssl\` and ensure \`pkg-config\` can find it.
Journey Context:
The developer adds a crate like \`reqwest\` with the \`native-tls\` feature or \`diesel\` with \`postgres\` to \`Cargo.toml\` and runs \`cargo build\`. The compilation proceeds through many Rust crates but fails at the final linking stage with a verbose error from the system linker \(\`ld\` on Linux, \`link.exe\` on Windows\) stating it cannot find \`-lssl\` or \`-lcrypto\`. The developer searches online and finds GitHub issues suggesting to set \`OPENSSL\_DIR\` or \`PKG\_CONFIG\_PATH\` environment variables. They try pointing these to various directories without success. They might try installing \`openssl\` via a package manager but only get the runtime libraries, not the development headers \(the \`.a\` or \`.so\` symlink with unversioned names and the \`.pc\` files for \`pkg-config\`\). The epiphany comes when they understand that \`-sys\` crates \(like \`openssl-sys\`\) are thin Rust wrappers that use Cargo build scripts to locate and link against pre-installed system libraries using \`pkg-config\` \(or \`vcpkg\` on Windows\). If \`pkg-config --libs openssl\` returns nothing or if the unversioned \`.so\` files \(like \`libssl.so\`\) are missing \(only versioned ones like \`libssl.so.3\` exist\), the linker fails. The fix works because installing the \`-dev\` or \`-devel\` package provides the unversioned symlinks and \`pkg-config\` metadata required by the build script to generate the correct \`-lssl\` linker argument.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:13:42.417560+00:00— report_created — created