简体   繁体   English

用Cargo构建opensl板条箱时遇到问题

[英]Problems building the openssl crate with Cargo

Whenever I try to compile I get 每当我尝试编译时,我都会得到

  = note: /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libnative_tls-e4af7be01e0cc1c7.rlib(native_tls-e4af7be01e0cc1c7.native_tls.c3tq55qu-cgu.0.rcgu.o): in function `<openssl::stack::StackRef<T>>::len':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/stack.rs:171: undefined reference to `sk_num'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libnative_tls-e4af7be01e0cc1c7.rlib(native_tls-e4af7be01e0cc1c7.native_tls.c3tq55qu-cgu.0.rcgu.o): in function `<openssl::stack::StackRef<T>>::_get':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/stack.rs:242: undefined reference to `sk_value'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.11.rcgu.o): in function `openssl::ssl::compat::tls_method':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/ssl/mod.rs:2546: undefined reference to `SSLv23_method'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.15.rcgu.o): in function `<openssl::stack::Stack<T>>::new':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/stack.rs:40: undefined reference to `sk_new_null'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.15.rcgu.o): in function `<openssl::stack::Stack<T> as core::ops::drop::Drop>::drop':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/stack.rs:50: undefined reference to `sk_free'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.15.rcgu.o): in function `<openssl::stack::StackRef<T>>::pop':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/stack.rs:232: undefined reference to `sk_pop'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.4.rcgu.o): in function `openssl::version::number':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/version.rs:51: undefined reference to `SSLeay'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl-a51d9ef9dbb88c83.rlib(openssl-a51d9ef9dbb88c83.openssl.27r2wowg-cgu.6.rcgu.o): in function `openssl::x509::compat::X509_up_ref':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.9.24/src/x509/mod.rs:1172: undefined reference to `CRYPTO_add_lock'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl_sys-51d0c50f2e67767f.rlib(openssl_sys-51d0c50f2e67767f.openssl_sys.afwyjyem-cgu.9.rcgu.o): in function `openssl_sys::init::{{closure}}':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:150: undefined reference to `SSL_library_init'
          /usr/bin/ld: /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:151: undefined reference to `SSL_load_error_strings'
          /usr/bin/ld: /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:152: undefined reference to `OPENSSL_add_all_algorithms_noconf'
          /usr/bin/ld: /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:154: undefined reference to `CRYPTO_num_locks'
          /usr/bin/ld: /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:164: undefined reference to `CRYPTO_set_locking_callback'
          /usr/bin/ld: /home/trent/Documents/projects/coding/rust/website/auth/target/debug/deps/libopenssl_sys-51d0c50f2e67767f.rlib(openssl_sys-51d0c50f2e67767f.openssl_sys.afwyjyem-cgu.9.rcgu.o): in function `openssl_sys::init::set_id_callback':
          /home/trent/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.40/src/lib.rs:139: undefined reference to `CRYPTO_set_id_callback'
          collect2: error: ld returned 1 exit status

Complete log 完整的日志

I have both OpenSSL and OpenSSL-1.0 installed. 我同时安装了OpenSSL和OpenSSL-1.0。 I have tried using both Rust stable and nightly. 我尝试过使用Rust稳定版和每晚使用。 I've also tried to include different versions of the openssl crate, but I think Cargo is just building the version of the crate that I think grpc is using. 我还尝试过包含不同版本的openssl板条箱,但我认为Cargo只是在构建我认为grpc正在使用的板条箱版本。 I'm on Arch Linux. 我在Arch Linux上。

Your project is using openssl 0.9.x (probably via tls-api-native-tls 0.1.x -> native-tls 0.1.x -> openssl 0.9.x ), which doesn't support OpenSSL 1.1.1. 您的项目使用的是openssl 0.9.x (可能是通过tls-api-native-tls 0.1.x > native-tls 0.1.x > openssl 0.9.x ),它不支持OpenSSL 1.1.1。 I'm also on Arch Linux and I've had to update my programs to openssl 0.10 in order to use OpenSSL 1.1.1. 我也在Arch Linux上,为了使用OpenSSL 1.1.1,我不得不将程序更新为openssl 0.10

In your case, tls-api-native-tls needs to be updated to depend on native-tls 0.2.x , which uses openssl 0.10.x (which does support OpenSSL 1.1.1). 在您的情况下,需要更新tls-api-native-tls以使其依赖于native-tls 0.2.x ,后者使用openssl 0.10.x (确实支持OpenSSL 1.1.1)。 There is an open issue about this. 关于此有一个未解决的问题。

If that's too complicated, you can also use various environment variables to tell openssl-sys 's build script which installation of OpenSSL you'd like to use. 如果太复杂了,您还可以使用各种环境变量来告诉openssl-sys的构建脚本您要使用哪种OpenSSL安装。 If you'd prefer using OpenSSL 1.0.x, enter the following commands in your shell: 如果您希望使用OpenSSL 1.0.x,请在您的Shell中输入以下命令:

$ cargo clean
$ OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0 OPENSSL_LIB_DIR=/usr/lib/openssl-1.0 cargo build

(Note: the paths above may be specific to Arch Linux.) (注意:以上路径可能特定于Arch Linux。)

For more information on the environment variables you can use to configure openssl-sys , see Manual configuration . 有关可用于配置openssl-sys的环境变量的更多信息,请参见“ 手动配置”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM