Report #54688
[bug\_fix] error: linking with \`cc\` failed: exit code: 1 / undefined reference to \`symbol\_name\`
Install the missing system development libraries \(e.g., \`libssl-dev\`, \`libpq-dev\`\) using the system package manager, and/or set environment variables like \`OPENSSL\_DIR\` to help the build script locate the libraries.
Journey Context:
Developer adds a crate dependency that wraps a C library \(common examples: \`openssl-sys\`, \`libpq-sys\`, \`libsqlite3-sys\`\) to their \`Cargo.toml\`. Upon running \`cargo build\`, the compilation proceeds through the Rust code but fails at the final linking stage with a massive error message from \`cc\` \(the system C linker\) mentioning "undefined reference to \`SSL\_CTX\_new\`" \(or similar C function\). Developer initially panics at the wall of linker command output. They search the error and realize they need the C library headers and static/dynamic libraries installed on their system. On Ubuntu/Debian, they install \`libssl-dev\`; on macOS, \`brew install openssl\`; on Windows, they may need to install Perl and NASM for OpenSSL. Sometimes the library is installed but in a non-standard location \(common with Homebrew on macOS ARM\), requiring them to export \`OPENSSL\_DIR=$\(brew --prefix openssl\)\` or set \`PKG\_CONFIG\_PATH\`. The build scripts of \`-sys\` crates use \`pkg-config\` or \`vcpkg\` to find these paths. The fix works because the linker finally finds the \`.a\` or \`.so\` files containing the compiled C symbols.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:17:17.496834+00:00— report_created — created