Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

rust - error: native library `openssl` is being linked to by more than one version of the same package

I'm facing this problem when I try to cargo build:

error: native library openssl is being linked to by more than one version of the same package, but it can only be linked once; try updating or pinning your dependencies to ensure that this package only shows up once

openssl-sys v0.6.7

openssl-sys v0.7.13

Cargo and Rust versions:

$ cargo --version
cargo 0.11.0-nightly (3ff108a 2016-05-24)

$ rustc --version
rustc 1.11.0-nightly (7746a334d 2016-05-28)

Files:

can't get why this doesn't compile and how to solve this problem. Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The way that linking works, you can only have a single version of a native library linked, otherwise you end up with duplicate symbols. Cargo's links manifest key helps prevent you from accidentally linking to the same set of symbols twice.

To solve it, you need to read through your Cargo.lock (it's not a difficult file format to understand). Find the crates that have the offending library as a dependency and note which ones have conflicting versions.

Then you have to manually resolve your dependencies so that their dependencies use the same version of the native library.


In this case, the important aspects of the dependency chain are:

server (0.0.1) => cookie (0.2.4) => openssl (0.7.13)
               => hyper (0.6.16) => cookie (0.1.21) => openssl (0.6.7)

To fix it, modify your Cargo.toml to use the same version of cookie as hyper. Then you will implicitly get the same version of openssl.

To be honest, this is one of the roughest parts of Rust at the moment. At least this version of the "multiple different versions of the same crate" strangeness provides a straight-forward Cargo error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...