Report #72201
[bug\_fix] linker error: undefined reference to symbol \(FFI/C library\)
Install the system development package \(e.g., \`libssl-dev\`, \`postgresql-devel\`\), then emit the link instruction in \`build.rs\`: \`println\!\("cargo:rustc-link-lib=dylib=ssl"\);\` and optionally \`cargo:rustc-link-search\` for non-standard paths. The root cause is that the Rust compiler successfully generates object files but the system linker \(\`ld\`, \`link.exe\`\) cannot find the native C library symbols or the library file itself during the final executable linking phase.
Journey Context:
Developer adds \`openssl = "0.10"\` to \`Cargo.toml\` on a fresh Ubuntu Docker image. \`cargo build\` fails with \`note: /usr/bin/ld: cannot find -lssl\`. The developer initially sets \`RUSTFLAGS="-L /usr/lib/x86\_64-linux-gnu"\` without success. They then realize the \`-dev\` package is missing and run \`apt-get install libssl-dev\`. The error persists when cross-compiling for ARM because the linker cannot find the ARM libraries. They create a \`build.rs\` file that detects the target architecture and emits \`println\!\("cargo:rustc-link-search=/opt/cross/lib"\);\` and \`cargo:rustc-link-lib=ssl\`, allowing Cargo to pass the correct flags to the linker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:46:31.848543+00:00— report_created — created