如何修复使用 Cargo 安装时 OpenSSL 的链接错误?

问题描述 投票:0回答:1

在 Ubuntu (WSL) 上运行

cargo install cargo-audit
时,我遇到了由于 OpenSSL 链接不正确而导致的问题。错误输出如下:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcB0ll0w/symbols.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.0.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.1.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.10.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.11.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.12.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.13.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.14.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.15.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.2.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.3.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.4.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.5.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.6.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.7.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.8.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.cargo_audit.4b2d1431-cgu.9.rcgu.o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d.5bgsmrqz64z6f24b.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/cargo-installLm5AI0/release/deps" "-L" "/tmp/cargo-installLm5AI0/release/build/libgit2-sys-ab710b2f3e7b993f/out/build" "-L" "/tmp/cargo-installLm5AI0/release/build/libssh2-sys-fe3958ab27ba2d9c/out/build" "-L" "/home/linuxbrew/.linuxbrew/Homebrew/Cellar/zlib/1.2.13/lib" "-L" "/home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib" "-L" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installLm5AI0/release/deps/libcargo_audit-ba31315c8226c5f7.rlib" "/tmp/cargo-installLm5AI0/release/deps/libquitters-8ca61fb4edd791cb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libauditable_info-102796539dc6db2a.rlib" "/tmp/cargo-installLm5AI0/release/deps/libminiz_oxide-8725d8ab3b903d72.rlib" "/tmp/cargo-installLm5AI0/release/deps/libauditable_serde-e49fc97ef8fb73e1.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtopological_sort-b80ee26172c691c5.rlib" "/tmp/cargo-installLm5AI0/release/deps/libauditable_extract-b46f7d79dc153747.rlib" "/tmp/cargo-installLm5AI0/release/deps/libbinfarce-d5768a31f688c163.rlib" "/tmp/cargo-installLm5AI0/release/deps/librustsec-a65865b6834de73e.rlib" "/tmp/cargo-installLm5AI0/release/deps/libhumantime_serde-1fae49580584b629.rlib" "/tmp/cargo-installLm5AI0/release/deps/libhumantime-1a664a869acbf690.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcrates_index-c399c2cd17b1eb36.rlib" "/tmp/cargo-installLm5AI0/release/deps/libhex-db1d35ea9d6a1256.rlib" "/tmp/cargo-installLm5AI0/release/deps/libhome-de7eea5412b68006.rlib" "/tmp/cargo-installLm5AI0/release/deps/libserde_json-ce84a909c801ce02.rlib" "/tmp/cargo-installLm5AI0/release/deps/libryu-88258a19faa64566.rlib" "/tmp/cargo-installLm5AI0/release/deps/libitoa-90093fe851f07a5b.rlib" "/tmp/cargo-installLm5AI0/release/deps/librustc_hash-4919b10a6960a6e7.rlib" "/tmp/cargo-installLm5AI0/release/deps/librayon-b095cd41cf8aa4c0.rlib" "/tmp/cargo-installLm5AI0/release/deps/librayon_core-6189c9eff1cfbf3c.rlib" "/tmp/cargo-installLm5AI0/release/deps/libnum_cpus-0c190f14f0fc9408.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcrossbeam_deque-6919af55eb962223.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcrossbeam_epoch-af08596d55c49a9f.rlib" "/tmp/cargo-installLm5AI0/release/deps/libmemoffset-ff92e730c41b6f16.rlib" "/tmp/cargo-installLm5AI0/release/deps/libscopeguard-44ce19bcdeca0676.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcrossbeam_channel-be99bd548d7514b2.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcrossbeam_utils-b24adb5fa2bf3b21.rlib" "/tmp/cargo-installLm5AI0/release/deps/libeither-94f44080c7bbad71.rlib" "/tmp/cargo-installLm5AI0/release/deps/libsmartstring-957ea11b2b795159.rlib" "/tmp/cargo-installLm5AI0/release/deps/libstatic_assertions-c411b8b1fba76a95.rlib" "/tmp/cargo-installLm5AI0/release/deps/libgit2-842c505f7985f68e.rlib" "/tmp/cargo-installLm5AI0/release/deps/libopenssl_probe-4cf2b797c3e467a5.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblibgit2_sys-0c824e993aa7e3f3.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblibssh2_sys-3b7d3a24eaaa39d4.rlib" "/tmp/cargo-installLm5AI0/release/deps/libopenssl_sys-ebd8c0fa3f47aeef.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblibz_sys-7aaab66cf419a3aa.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcargo_lock-be07c6367552a9bb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libpetgraph-e416ce50433790ed.rlib" "/tmp/cargo-installLm5AI0/release/deps/libfixedbitset-c0ab716b5c464607.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcvss-9ec32b092571c47b.rlib" "/tmp/cargo-installLm5AI0/release/deps/liburl-f1573f0ec05b4ed0.rlib" "/tmp/cargo-installLm5AI0/release/deps/libidna-6f902c6f2d9eccc8.rlib" "/tmp/cargo-installLm5AI0/release/deps/libunicode_normalization-341a4973ba613a10.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtinyvec-06f54cf1e70c699a.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtinyvec_macros-7ea1a6b76c72a9dc.rlib" "/tmp/cargo-installLm5AI0/release/deps/libunicode_bidi-1f8a20476c281f45.rlib" "/tmp/cargo-installLm5AI0/release/deps/libform_urlencoded-046ca41e80054c9f.rlib" "/tmp/cargo-installLm5AI0/release/deps/libpercent_encoding-b1507e4fb94d80b2.rlib" "/tmp/cargo-installLm5AI0/release/deps/libplatforms-897be36d4779e56e.rlib" "/tmp/cargo-installLm5AI0/release/deps/libthiserror-fd7a0bd9bc45d6aa.rlib" "/tmp/cargo-installLm5AI0/release/deps/libabscissa_core-2ce6f80a63620bda.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcolor_eyre-648d323a7e6a3015.rlib" "/tmp/cargo-installLm5AI0/release/deps/libowo_colors-7d2ce5db4296ab30.rlib" "/tmp/cargo-installLm5AI0/release/deps/libeyre-d19b2192a7971412.rlib" "/tmp/cargo-installLm5AI0/release/deps/libindenter-5f20979778cb29af.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtoml-090d5cf3d168bcfd.rlib" "/tmp/cargo-installLm5AI0/release/deps/libsemver-8ccfd42fd72cae17.rlib" "/tmp/cargo-installLm5AI0/release/deps/libsecrecy-16ab41c42157d021.rlib" "/tmp/cargo-installLm5AI0/release/deps/libzeroize-5354e4ec9b6a796d.rlib" "/tmp/cargo-installLm5AI0/release/deps/libfs_err-1726d94da0b217b7.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtracing_subscriber-4a092f8e8a9a6097.rlib" "/tmp/cargo-installLm5AI0/release/deps/libsmallvec-99a8bb7ea5f51bfc.rlib" "/tmp/cargo-installLm5AI0/release/deps/libnu_ansi_term-f0bc8b7a6d1c0d65.rlib" "/tmp/cargo-installLm5AI0/release/deps/liboverload-7053c77e45b4b3ca.rlib" "/tmp/cargo-installLm5AI0/release/deps/libsharded_slab-8f8b135bb8aa4daa.rlib" "/tmp/cargo-installLm5AI0/release/deps/libmatchers-e070fccb21f1e6bd.rlib" "/tmp/cargo-installLm5AI0/release/deps/libregex_automata-bec29b835733ab70.rlib" "/tmp/cargo-installLm5AI0/release/deps/libregex-84ca085d1e4b9054.rlib" "/tmp/cargo-installLm5AI0/release/deps/libaho_corasick-4d4faeb11a367553.rlib" "/tmp/cargo-installLm5AI0/release/deps/libregex_syntax-c73e2ff9e4cb1271.rlib" "/tmp/cargo-installLm5AI0/release/deps/libthread_local-0977d16a9e0d4c6b.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtracing_log-a52de5f67c2ebe93.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblog-bff571ca34590620.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblazy_static-3e723a0d9ba3ed98.rlib" "/tmp/cargo-installLm5AI0/release/deps/libwait_timeout-515e2e53d753e05e.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcanonical_path-f97347f53823818f.rlib" "/tmp/cargo-installLm5AI0/release/deps/libserde-b3addfd966520914.rlib" "/tmp/cargo-installLm5AI0/release/deps/libarc_swap-dacda09a8706e415.rlib" "/tmp/cargo-installLm5AI0/release/deps/libclap-231554819eeba9cb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libatty-1fd8a44ba70a1dc1.rlib" "/tmp/cargo-installLm5AI0/release/deps/libstrsim-824334d5c501d24b.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtextwrap-716750743ee1ccac.rlib" "/tmp/cargo-installLm5AI0/release/deps/libclap_lex-04d841fb1a97b99b.rlib" "/tmp/cargo-installLm5AI0/release/deps/libos_str_bytes-3c132b74e0da615b.rlib" "/tmp/cargo-installLm5AI0/release/deps/libindexmap-44b0f2a674bf2759.rlib" "/tmp/cargo-installLm5AI0/release/deps/libhashbrown-27b6f2397f551030.rlib" "/tmp/cargo-installLm5AI0/release/deps/libbitflags-06aa51f4326298eb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtermcolor-ec841bbc4169fa9c.rlib" "/tmp/cargo-installLm5AI0/release/deps/libbacktrace-ad763f54bed6d8d9.rlib" "/tmp/cargo-installLm5AI0/release/deps/libminiz_oxide-58e8c29f3db492bb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libadler-9552aedbb45d1598.rlib" "/tmp/cargo-installLm5AI0/release/deps/libobject-b4bd20bc925da023.rlib" "/tmp/cargo-installLm5AI0/release/deps/libmemchr-9c95114e5f38124a.rlib" "/tmp/cargo-installLm5AI0/release/deps/liblibc-99339f5a79aaa8cb.rlib" "/tmp/cargo-installLm5AI0/release/deps/libaddr2line-8dde0ea722a04182.rlib" "/tmp/cargo-installLm5AI0/release/deps/libgimli-9b7e907c0b57cebd.rlib" "/tmp/cargo-installLm5AI0/release/deps/librustc_demangle-48988ae44e48e6bd.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtracing-8217939ce9537676.rlib" "/tmp/cargo-installLm5AI0/release/deps/libcfg_if-e992930462a8ea8f.rlib" "/tmp/cargo-installLm5AI0/release/deps/libpin_project_lite-0f9cb4a11bbf6dad.rlib" "/tmp/cargo-installLm5AI0/release/deps/libtracing_core-58ae5d0d2459b867.rlib" "/tmp/cargo-installLm5AI0/release/deps/libonce_cell-b4df9561ab6b1506.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-05737cf45bd30456.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9f873b61fdec9b03.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-7f13930fcac1846f.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-098633b847612f3b.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-f14b73d282b0245e.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-2c5b4433ebc1d822.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-59591a7b405fe395.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-384947c6d5f697ff.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-b08a86c6880b47a8.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-58adeee671f9ba8e.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-f156b880fc73e7f0.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-4458c5022988e1ab.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-02e61e5ec4aa9e8b.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-a0d9b33b5161957b.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-04cec55a79224c36.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-3fb6d8496dc7d6a6.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-7d46c016841a97d4.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-a1f7b8b60464cc57.rlib" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-272ca28f0b8538d5.rlib" "-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lz" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/cargo-installLm5AI0/release/deps/cargo_audit-feda7ef5d9ac673d" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs"
  = note: /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_setspecific@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `dlopen@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_rwlock_init@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_rwlock_wrlock@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `dlerror@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_getspecific@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `dlclose@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_rwlock_rdlock@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_key_delete@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `fstat@GLIBC_2.33'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `stat@GLIBC_2.33'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_once@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `dladdr@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_rwlock_destroy@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_key_create@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `pthread_rwlock_unlock@GLIBC_2.34'
          /bin/ld: /home/linuxbrew/.linuxbrew/Homebrew/Cellar/[email protected]/1.1.1s/lib/libcrypto.so: undefined reference to `dlsym@GLIBC_2.34'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `cargo-audit` due to previous error
error: failed to compile `cargo-audit v0.17.4`, intermediate artifacts can be found at `/tmp/cargo-installLm5AI0`

我安装了 linuxbrew,并尝试安装 glibc 我收到一条消息,显示它已安装,但版本为 2.35:

glibc 2.35_1 is already installed and up-to-date.

我尝试通过从 GNU 下载存档来安装 glibc 2.34,但这也不起作用。

我希望它能正常安装,我在尝试安装cargo-tarpaulin和cargo-edit时也遇到了同样的问题。

rust openssl rust-cargo
1个回答
1
投票

--features vendored-openssl
附加到货物命令可以修复此问题。例如,在本例中为
cargo install cargo-audit --features vendored-openssl

© www.soinside.com 2019 - 2024. All rights reserved.