Skip to content

Commit

Permalink
Merge pull request #133 from 1ndahous3/win_static_openssl
Browse files Browse the repository at this point in the history
Add support of static linking with OpenSSL on Windows
  • Loading branch information
Hugal31 committed Nov 17, 2023
2 parents 30a0cdc + 5ea1ee2 commit d41d947
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions yara-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,20 @@ mod build {
.as_str()
== "windows"
{
println!("cargo:rustc-link-lib=dylib=libssl");
println!("cargo:rustc-link-lib=dylib=libcrypto");
println!("cargo:rustc-link-lib=dylib=Crypt32");
println!("cargo:rustc-link-lib=dylib=Ws2_32")
println!("cargo:rustc-link-lib=dylib=Ws2_32");
if cfg!(feature = "openssl-static") {
// since both static and dynamic linking force the linker to use "libssl.lib" and "libcrypto.lib"
// make sure you are linking against the static version:
// - libssl.lib is actually libssl_static.lib/libsslMT.lib
// - libcrypto.lib is actually libcrypto_static.lib/libcryptoMT.lib
// SA: https://github.com/Kitware/CMake/blob/32342fa728e636a220f3cbd8380097e8aa7852ad/Modules/FindOpenSSL.cmake#L387-L410
println!("cargo:rustc-link-lib=static=libssl");
println!("cargo:rustc-link-lib=static=libcrypto");
} else {
println!("cargo:rustc-link-lib=dylib=libssl");
println!("cargo:rustc-link-lib=dylib=libcrypto");
}
} else if cfg!(feature = "openssl-static") {
println!("cargo:rustc-link-lib=static=ssl");
println!("cargo:rustc-link-lib=static=crypto");
Expand Down

0 comments on commit d41d947

Please sign in to comment.