From c0ad27d87363b90dd97198cd4355030246cd9c72 Mon Sep 17 00:00:00 2001 From: Nathaniel Daniel Date: Sat, 19 Apr 2025 18:52:50 -0700 Subject: [PATCH] Link with required libs on Windows --- libmimalloc-sys/build.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libmimalloc-sys/build.rs b/libmimalloc-sys/build.rs index 22ee917..8a28f84 100644 --- a/libmimalloc-sys/build.rs +++ b/libmimalloc-sys/build.rs @@ -63,4 +63,14 @@ fn main() { let atomic_name = env::var("DEP_ATOMIC").unwrap_or("atomic".to_owned()); println!("cargo:rustc-link-lib={}", atomic_name); } + + // Link with libs needed on Windows + if target_os == "windows" { + // https://github.com/microsoft/mimalloc/blob/af21001f7a65eafb8fb16460b018ebf9d75e2ad8/CMakeLists.txt#L487 + let libs = ["psapi", "shell32", "user32", "advapi32", "bcrypt"]; + + for lib in libs { + println!("cargo:rustc-link-lib={}", lib); + } + } }