Report #84893
[bug\_fix] ld: library not found for -lssl \(or -lcrypto, -lsqlite3\) during cargo build
Install the missing system development packages \(e.g., \`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on RHEL/Fedora, \`openssl\` via Homebrew on macOS\) and ensure \`pkg-config\` can locate them. Root cause: The Rust crate \(typically a \`-sys\` crate like \`openssl-sys\`\) uses a \`build.rs\` script to link against a native C library, but the linker cannot find the library binary or headers on the host system.
Journey Context:
Developer adds a dependency like \`reqwest\` with native-tls, or \`rusqlite\`, or \` diesel\` to their Cargo.toml and runs \`cargo build\`. Instead of compiling, the build script fails with a cryptic linker error mentioning \`-lssl\` or \`-lsqlite3\` and paths like \`/usr/bin/ld: cannot find -lssl\`. Developer panics, thinking Rust is broken. They search the error and find GitHub issues on the \`openssl-sys\` or \`libsqlite3-sys\` crates explaining that system libraries are required. On Ubuntu, they run \`sudo apt-get install libssl-dev pkg-config\`. On macOS, they realize they need \`brew install openssl\` and export \`PKG\_CONFIG\_PATH=$\(brew --prefix openssl\)/lib/pkgconfig\` because macOS doesn't ship OpenSSL headers. They re-run cargo build, the -sys crate's build.rs finds the library via pkg-config, emits the correct cargo:rustc-link-lib directives, and linking succeeds. Developer learns that Rust's FFI relies on the host C toolchain and that \`-sys\` crates are just orchestrating the platform linker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:04:51.280800+00:00— report_created — created