1

我向 Cargo.toml 添加了 openssl 依赖项。

[dependencies.openssl]
openssl = "0.2.12"

但是当我尝试构建和执行时,由于以下原因,它无法编译该板条箱:

type std::sync::mutex::StaticMutexGuard does not implement any method in scope named unwrap

完整输出:

pablo@boreth:~/pruebas/rust/hello_world$ cargo run --verbose
       Fresh pkg-config v0.1.3
   Compiling openssl-sys v0.2.12
     Running `rustc /home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs --crate-name openssl-sys --crate-type lib -g -C metadata=e45df04b75965aa1 -C extra-filename=-e45df04b75965aa1 --out-dir /home/pablo/pruebas/rust/hello_world/target/deps --emit=dep-info,link -L /home/pablo/pruebas/rust/hello_world/target/deps -L /home/pablo/pruebas/rust/hello_world/target/deps -Awarnings -L native=/usr/lib/x86_64-linux-gnu -l ssl -l crypto`
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:203:54: 203:62 error: type `std::sync::mutex::StaticMutexGuard` does not implement any method in scope named `unwrap`
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:203             (*GUARDS)[n as uint] = Some(mutex.lock().unwrap());
                                                                                                                                                   ^~~~~~~~
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:214:14: 226:11 error: type `std::sync::once::Once` does not implement any method in scope named `call_once`
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:214         INIT.call_once(|| {
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:215             SSL_library_init();
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:216             SSL_load_error_strings();
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:217
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:218             let num_locks = CRYPTO_num_locks();
/home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs:219             let mutexes = box range(0, num_locks).map(|_| MUTEX_INIT).collect::<Vec<_>>();
                                                                                              ...
error: aborting due to 2 previous errors
Could not compile `openssl-sys`.

Caused by:
  Process didn't exit successfully: `rustc /home/pablo/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.2.12/src/lib.rs --crate-name openssl-sys --crate-type lib -g -C metadata=e45df04b75965aa1 -C extra-filename=-e45df04b75965aa1 --out-dir /home/pablo/pruebas/rust/hello_world/target/deps --emit=dep-info,link -L /home/pablo/pruebas/rust/hello_world/target/deps -L /home/pablo/pruebas/rust/hello_world/target/deps -Awarnings -L native=/usr/lib/x86_64-linux-gnu -l ssl -l crypto` (status=101)

我正在使用 Ubuntu Ubuntu 14.04.1 LTS (Trusty Tahr),并且我已经安装了 libssl-dev。

pablo@boreth:~$ uname -a
Linux boreth 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
pablo@boreth:~$ dpkg -l libssl-dev
Deseado=Desconocido/Instalar/Eliminar/Purgar/Retener
| Estado=No/Instalado/Config-files/Desempaquetado/Medio-conf/Medio-inst/espera-disparo/pendiente-disparo
|/ Err?=(ninguno)/Requiere-reinst (Estado,Err: mayúsc.=malo)
||/ Nombre                                     Versión                    Arquitectura               Descripción
+++-==========================================-==========================-==========================-=========================================================================================
ii  libssl-dev:amd64                           1.0.1f-1ubuntu2.7          amd64                      Secure Sockets Layer toolkit - development files

rustc 和 cargo 版本:

$ rustc -V
rustc 0.13.0-nightly (636663172 2014-12-28 16:21:58 +0000)
$ cargo -V
cargo 0.0.1-pre-nightly (26ac282 2014-12-30 00:13:39 +0000)

有谁知道解决方案还是我应该等待更新?

4

1 回答 1

0

我有同样的问题:只需更新 rust 并重新编译项目

rustup update
于 2021-07-02T13:58:00.507 回答