-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
I am getting a linker error when trying to build for the x86_64-pc-windows-gnu target.
My executable links correctly for the x86_64-pc-windows-msvc target.
The root cause is that the MSVC and GNU compiler expect linker libraries to be specified differently (i.e., with or without the lib prefix).
The patch below applied to build.rs fixes the problem.
Compiler detection is based on the scheme implemented in the openssl-sys crate.
--- ./vendor/libssh-rs-sys-0.2.6/build.rs
+++ ./patch/libssh-rs-sys-0.2.6/build.rs
@@ -260,8 +260,15 @@
cfg.compile("libssh");
if target.contains("windows") {
- println!("cargo:rustc-link-lib=libcrypto");
- println!("cargo:rustc-link-lib=libssl");
+ if target.contains("windows-msvc") {
+ // target `windows-msvc` expects `lib` prefix
+ println!("cargo:rustc-link-lib=libcrypto");
+ println!("cargo:rustc-link-lib=libssl");
+ } else {
+ // target `windows-gnu` adds the `lib` prefix
+ println!("cargo:rustc-link-lib=crypto");
+ println!("cargo:rustc-link-lib=ssl");
+ }
println!("cargo:rustc-link-lib=crypt32");
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=shell32");
Metadata
Metadata
Assignees
Labels
No labels