Report #61975
[bug\_fix] error: linking with \`cc\` failed: exit status: 1 ... undefined reference to \`SSL\_CTX\_new\`
Install the required system development packages \(e.g., \`sudo apt-get install libssl-dev pkg-config\` on Debian/Ubuntu, \`sudo dnf install openssl-devel\` on RHEL/Fedora, or \`brew install openssl\` on macOS\) and ensure \`pkg-config\` can locate them. For custom OpenSSL installations, set the \`OPENSSL\_DIR\` environment variable.
Journey Context:
A developer clones a Rust project using \`reqwest\` with \`native-tls\` \(or the \`openssl\` crate directly\) onto a fresh GitHub Codespaces instance or a minimal CI container. \`cargo build\` compiles hundreds of crates successfully, then fails at the final linking stage with \`error: linking with cc failed\` and \`undefined reference to SSL\_CTX\_new\`, \`ld: cannot find -lssl\`, or similar. The developer checks that \`openssl\` is installed via \`openssl version\`, but the error persists. Searching reveals that the Rust linker needs the development headers and static/dynamic libraries \(\`libssl.so\`, \`libcrypto.so\`\), not just the CLI binary. The developer installs \`libssl-dev\` \(Debian\) or \`openssl-devel\` \(RHEL\) which provides the \`.pc\` files for \`pkg-config\` used by the \`openssl-sys\` build script. The build script then emits the correct \`cargo:rustc-link-lib=ssl\` flags. Recompiling succeeds. The journey teaches the distinction between compile-time Rust crates and runtime system library linking, the role of \`pkg-config\`, and the necessity of \`-dev\` packages on Linux.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:30:50.364278+00:00— report_created — created