Closed idubrov closed 4 years ago
This also happens on macOS 10.12 Sierra
This may be the same root cause as https://github.com/alexcrichton/ssh2-rs/issues/174 I've just published 0.2.17 to address that other issue; could you try with that and let me know if this is still a problem?
Assuming that this is resolved.
Oops, sorry, missed previous notification. Yes, indeed it works now! Thanks a lot!
Simplest program depending on
libssh2-sys = "0.2.16"
and doinglibssh2_sys::init();
fails on macOS 10.14.6 Mojave.Here is the project: https://github.com/idubrov/openssl-macos-issue
For convenience, this is all it is:
Cargo.toml
src/main.rs:
Steps to reproduce: run
cargo run
on macOSResults:
Investigating the cause revealed that wrong openssl library is being linked.
Note that it passes
"-L" "/usr/local/opt/openssl@1.1/lib"
, which is the version I want to link to. However, in front of it, there is"-L" "/usr/lib"
, which makes linker to look in system directory and link to the version of OpenSSL shipped with macOS (which is 0.9).Running
cargo -vv run
reveals the following piece of configuration emitted bylibssh2-sys
build:Which, I think, is the cause for the error above.
To confirm, I added
-Xlinker -v
argument to the"cc"
command above and got the following listing:Note how
/usr/lib
is included twice -- once before/usr/local/opt/openssl@1.1/lib
and once after. I think, the latter is added by default. However, the former one, I think, is caused bylibssh2-sys
build.To summarize:
libssh2-sys
build adds/usr/lib
as a search path for libraries.openssl-sys
build adds/usr/local/opt/openssl@1.1/lib
as a search path for libraries. It, however, goes after/usr/lib
.openssl-sys
uses includes from/usr/local/opt/openssl@1.1/include
(correct), but when final binary is linked, it is linked against openssl in/usr/lib
(incorrect).I think this is an issue with
libssh2-sys
build (but could be caused by downstream libraries like,pkg_config
).(also, reported to
openssl
crate for visibility https://github.com/sfackler/rust-openssl/issues/1252)