Report #96831
[bug\_fix] Cargo linker error: undefined reference to \`SSL\_CTX\_new\` \(OpenSSL\)
Install OpenSSL development packages \(\`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on RHEL/Fedora, \`openssl\` via Homebrew on macOS\) or set \`OPENSSL\_DIR\` environment variable to a custom OpenSSL installation. Root cause: The \`openssl-sys\` crate's build script uses \`pkg-config\` or \`vcpkg\` to locate system SSL libraries; if headers \(\`.h\`\) or static/shared libraries \(\`.a\`/\`.so\`/\`.dll\`\) are missing, the linker fails to resolve C symbols required by the Rust bindings.
Journey Context:
Developer adds \`reqwest\` \(with native-tls\) or \`openssl\` crate to \`Cargo.toml\` and runs \`cargo build\`. The build fails at the linking stage with \`undefined reference to SSL\_CTX\_new\` or \`cannot find -lssl\`. Developer initially thinks Rust is missing a crate, but realizes it's a system dependency. They search the error and find GitHub issues for \`rust-openssl\` explaining platform-specific package names. On Ubuntu they run \`sudo apt-get install libssl-dev\`. On macOS with Homebrew, they might need \`export OPENSSL\_DIR=/usr/local/opt/openssl\`. The build succeeds because \`openssl-sys\`'s build script detects the installed libraries via \`pkg-config\`, emitting \`cargo:rustc-link-lib=ssl\` instructions to the linker, allowing resolution of the C FFI symbols.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:06:52.543276+00:00— report_created — created