diff --git a/examples/cxx/build-and-run-crashinfo.ps1 b/examples/cxx/build-and-run-crashinfo.ps1 index bd920608c5..f48ff6002c 100644 --- a/examples/cxx/build-and-run-crashinfo.ps1 +++ b/examples/cxx/build-and-run-crashinfo.ps1 @@ -109,7 +109,8 @@ if ($USE_MSVC) { Write-Host "Using MSVC compiler" -ForegroundColor Yellow # MSVC compilation - cl.exe /std:c++20 /EHsc ` + # Use /MD (dynamic CRT) to match the default Rust build + cl.exe /std:c++20 /EHsc /MD ` /I"$CXX_BRIDGE_INCLUDE" ` /I"$CXX_BRIDGE_CRATE" ` /I"$RUST_CXX_INCLUDE" ` @@ -118,6 +119,7 @@ if ($USE_MSVC) { "$CRASHTRACKER_LIB" ` "$CXX_BRIDGE_LIB" ` ws2_32.lib advapi32.lib userenv.lib ntdll.lib bcrypt.lib ` + dbghelp.lib psapi.lib ole32.lib powrprof.lib ` /Fe:examples\cxx\crashinfo.exe if ($LASTEXITCODE -ne 0) { @@ -137,7 +139,9 @@ if ($USE_MSVC) { examples/cxx/crashinfo.cpp ` "$CXX_BRIDGE_LIB" ` "$CRASHTRACKER_LIB" ` - -lws2_32 -ladvapi32 -luserenv -lntdll -lbcrypt -lgcc_eh -lpthread ` + -lws2_32 -ladvapi32 -luserenv -lntdll -lbcrypt ` + -ldbghelp -lpsapi -lole32 -lpowrprof ` + -lgcc_eh -lpthread ` -o examples/cxx/crashinfo.exe if ($LASTEXITCODE -ne 0) { diff --git a/libdd-crashtracker/build.rs b/libdd-crashtracker/build.rs index f2ca83ab4d..de67741621 100644 --- a/libdd-crashtracker/build.rs +++ b/libdd-crashtracker/build.rs @@ -15,9 +15,14 @@ pub use libdd_common::cc_utils::cc; // Build CXX bridge - cross-platform function #[cfg(feature = "cxx")] fn build_cxx_bridge() { - cxx_build::bridge("src/crash_info/cxx.rs") - .flag_if_supported("-std=c++20") - .compile("libdd-crashtracker-cxx"); + let mut build = cxx_build::bridge("src/crash_info/cxx.rs"); + build.flag_if_supported("-std=c++20"); + + // On Windows, use dynamic CRT (/MD) to match the default Rust build + #[cfg(target_os = "windows")] + build.static_crt(false); + + build.compile("libdd-crashtracker-cxx"); println!("cargo:rerun-if-changed=src/crash_info/cxx.rs"); }