由于 openssl-0.10.45/src/error.rs:122: 未定义对 `ERR_get_error_all' 的引用,货物构建失败

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

我正在实现一个基于 Rust 的 cli 工具。

我可以在其他机器上构建并运行代码,但无法在Linux内核5.19的机器上运行它:

yaoxin@amd-sev-snp2:~/Trusted_Client$ uname -r
5.19.0-rc6-snp-host-d9bd54fea4d2

我运行时收到以下错误消息

cargo build

    = note: `#[warn(dead_code)]` on by default

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/yaoxin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/yaoxin/.vscode-server/bin/e7f30e38c5a4efafeec8ad52861eb772a9ee4dfb/bin/remote-cli:**-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/yaoxin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/yaoxin/Trusted_Client/target/debug/deps/secure_client-71eef312d680d6a9" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"**
  = note: /usr/bin/ld: /home/yaoxin/Trusted_Client/target/debug/deps/libopenssl-dff11c4997429b22.rlib(openssl-dff11c4997429b22.openssl.873f3124-cgu.7.rcgu.o): in function `openssl::error::Error::get':
          /home/yaoxin/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.10.45/src/error.rs:122: undefined reference to `ERR_get_error_all'
          collect2: error: ld returned 1 exit status
          
  = note: 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)

warning: `secure-client` (bin "secure-client") generated 1 warning
error: could not compile `secure-client` due to previous error; 1 warning emitted

我已经安装了

libssl-dev
:

yaoxin@amd-sev-snp2:~/Trusted_Client$ apt show libssl-dev
Package: libssl-dev
Version: 1.1.1f-1ubuntu2.17
Priority: optional
Section: libdevel
Source: openssl
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian OpenSSL Team <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 8.016 kB
Depends: libssl1.1 (= 1.1.1f-1ubuntu2.17)
Suggests: libssl-doc
Conflicts: libssl1.0-dev
Homepage: https://www.openssl.org/
Download-Size: 1.585 kB
APT-Manual-Installed: yes
APT-Sources: http://de.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Description: Secure Sockets Layer toolkit - development files
 This package is part of the OpenSSL project's implementation of the SSL
 and TLS cryptographic protocols for secure communication over the
 Internet.
 .
 It contains development libraries, header files, and manpages for libssl
 and libcrypt.

N: There is 1 additional record. Please use the '-a' switch to see it

我已经链接了

-lssl" "-lcrypto"

你有什么想法吗?

rust openssl linker linker-errors rust-cargo
1个回答
0
投票

openssl crate自动检测OpenSSL版本,我遇到了同样的错误,因为我在Ubuntu服务器上安装了openssl3,并删除了openssl3的部分文件。要彻底删除 openssl3,您应该删除 include、libs、pkg-config 文件。

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