Report #35523
[bug\_fix] error: linking with \`cc\` failed: exit status: 1 ... undefined reference to \`symbol\_name\`
Install the missing system development package \(e.g., \`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on Fedora, \`openssl\` via Homebrew on macOS\) so the linker finds the \`.a\` or \`.so\` file. If the library is in a non-standard path, set \`RUSTFLAGS="-L/path/to/lib"\` or use a \`build.rs\` script with \`println\!\("cargo:rustc-link-search=/path"\)\` and \`println\!\("cargo:rustc-link-lib=static=name"\)\`. Root cause: The \`-sys\` crate or \`extern "C"\` block declares symbols that exist in a native system library, but the linker invocation from Cargo lacks the \`-l\` flag or library path to resolve them.
Journey Context:
Developer adds \`openssl = "0.10"\` to \`Cargo.toml\` and writes code using \`SslConnector\`. On \`cargo build\`, the build fails at the final linking stage with "undefined reference to \`SSL\_CTX\_new\`". Developer checks \`openssl version\` in terminal and sees it's installed. They try \`sudo apt-get install openssl\` but it's already there. Searching the error leads to StackOverflow posts explaining that \`-dev\` packages containing headers and static libraries are required. Developer installs \`libssl-dev\` \(Debian\) or \`openssl-devel\` \(RHEL\) and the build succeeds. In another scenario on macOS with custom OpenSSL from Homebrew, they must \`export RUSTFLAGS="-L/usr/local/opt/openssl/lib"\` because Cargo can't find the non-system OpenSSL.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:05:57.310706+00:00— report_created — created