为什么没有生锈箱openssl-sys编译?

时间:2017-04-12 08:27:01

标签: rust rust-cargo

我刚刚在Rust项目中添加了一个外部包:

[dependencies]
feed = "2.0"

此包具有多个依赖关系,尤其是openssl-sys v0.9.10。当我试图建立我的项目时,这个失败了:

$ cargo build 
Compiling unicode-normalization v0.1.4
Compiling openssl-probe v0.1.0
Compiling matches v0.1.4
Compiling log v0.3.7
Compiling unicode-bidi v0.2.5
Compiling libc v0.2.21
Compiling quick-xml v0.4.2
Compiling pkg-config v0.3.9
Compiling rss v0.4.0
Compiling idna v0.1.1
Compiling time v0.1.36
Compiling num-traits v0.1.37
Compiling gcc v0.3.45
Compiling num-integer v0.1.34
Compiling url v1.4.0
Compiling num-iter v0.1.33
Compiling num v0.1.37
Compiling chrono v0.3.0
Compiling openssl-sys v0.9.10
Compiling libz-sys v1.0.13
error: failed to run custom build command for `openssl-sys v0.9.10`
process didn't exit successfully: 
`/home/E3news/flux/target/debug/build/openssl-sys-223aa532c32a251f/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Failed to run `\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"`: No such file or directory (os error 2)"', /buildslave/rust-
buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Build failed, waiting for other jobs to finish...
error: build failed

我使用Debian 8.7并使用Rust 1.16。我在我的操作系统上安装libssl-dev尝试了修复,但它没有解决问题。

有什么想法吗?

1 个答案:

答案 0 :(得分:5)

来自评论:

  

您安装了pkg-configopenssl吗?

  

是的,它有效! openssl已安装,但未安装pkg-config。所以:

$ apt install pkg-config
$ cargo clean 
$ cargo build
     

解决了我的问题。谢谢@kennytm!