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

时间:2019-01-28 18:05:10

标签: linux rust archlinux rust-cargo

每当我尝试编译时,我都会得到

  = 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

我同时安装了OpenSSL和OpenSSL-1.0。我尝试过使用Rust稳定版和每晚使用。我还尝试过包含不同版本的openssl板条箱,但我认为Cargo只是在构建我认为grpc正在使用的板条箱版本。我在Arch Linux上。

1 个答案:

答案 0 :(得分:2)

您的项目正在使用openssl 0.9.x(可能通过tls-api-native-tls 0.1.x-> native-tls 0.1.x-> openssl 0.9.x),它不支持OpenSSL 1.1.1。我也在Arch Linux上,为了使用OpenSSL 1.1.1,必须将程序更新为openssl 0.10

在您的情况下,tls-api-native-tls需要更新以依赖native-tls 0.2.x,后者使用openssl 0.10.x(确实支持OpenSSL 1.1.1)。 There is an open issue about this.

如果太复杂了,您还可以使用各种环境变量来告诉openssl-sys的构建脚本您要使用哪种OpenSSL安装。如果您希望使用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

(注意:以上路径可能特定于Arch Linux。)

有关可用于配置openssl-sys的环境变量的更多信息,请参见Manual configuration