Report #57617
[bug\_fix] linker error: undefined reference to \`symbol\` or cannot find \`-lfoo\`
Install the native library's development packages \(e.g., \`libssl-dev\` on Debian/Ubuntu, \`openssl-devel\` on RHEL, \`brew install openssl\` on macOS\). Ensure \`pkg-config\` is installed and \`PKG\_CONFIG\_PATH\` points to the library's \`.pc\` files if installed in a non-standard location \(common with Homebrew\). For \`-sys\` crates, ensure the environment variables the \`build.rs\` expects \(e.g., \`LIBFOO\_LIB\_DIR\`, \`LIBFOO\_INCLUDE\_DIR\`\) are set if not using pkg-config. Root cause: The C linker \(\`ld\`, \`lld\`, \`link.exe\`\) needs the archive files \(\`.a\`\) or shared objects \(\`.so\`/\`.dylib\`\) of native libraries to resolve external symbols, and they are either missing from the system or not in the search path.
Journey Context:
Developer adds \`reqwest = \{ version = "0.11", features = \["native-tls"\] \}\` to \`Cargo.toml\` on a fresh Ubuntu Docker image. \`cargo build\` compiles dependencies then fails with "error: linking with \`cc\` failed" and "note: /usr/bin/ld: cannot find -lssl: No such file or directory". Developer realizes the system lacks OpenSSL development headers. They run \`apt-get update && apt-get install -y libssl-dev pkg-config\`. On macOS with Homebrew, after \`brew install openssl\`, they might still see the error because Homebrew is "keg-only"; they must \`export PKG\_CONFIG\_PATH="/opt/homebrew/opt/openssl/lib/pkgconfig"\` \(or \`/usr/local\` on Intel\). For a custom C library \`libfoo.a\`, they might need to set \`FOO\_LIB\_DIR\` and \`FOO\_INCLUDE\_DIR\` based on the \`-sys\` crate's documentation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T03:11:55.366272+00:00— report_created — created