diff --git a/build.rs b/build.rs index d470682..4d6f23a 100644 --- a/build.rs +++ b/build.rs @@ -5,6 +5,13 @@ fn main() { let src = PathBuf::from("src"); let mut bridge = cxx_build::bridge(src.join("bridge.rs")); + // Use the correct C++ standard library for the target platform + let cpp_stdlib = if cfg!(target_os = "macos") { + "c++" + } else { + "stdc++" + }; + assert!(bridge.is_flag_supported("-std=c++14").expect("supported")); bridge .files(&[ @@ -15,7 +22,7 @@ fn main() { ]) .include(datasketches.join("common").join("include")) .flag_if_supported("-std=c++14") - .cpp_link_stdlib("stdc++") + .cpp_link_stdlib(cpp_stdlib) .static_flag(true) .compile("libdatasketches.a"); }