Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,24 @@ fn patch_model_for_full_tflite(model_dir: &Path, use_full_tflite: bool) {
}
}

fn link_with_standard_library() {
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-lib=stdc++");
} else if cfg!(target_os = "macos") {
println!("cargo:rustc-link-lib=c++");
} else if cfg!(target_os = "windows") {
if cfg!(target_env = "msvc") {
println!("cargo:rustc-link-lib=msvcrt");
} else {
println!("cargo:rustc-link-lib=stdc++"); // MinGW
}
} else {
println!("cargo:warning=Unknown platform, defaulting to stdc++");
println!("cargo:rustc-link-lib=stdc++");
}
}


fn main() {
println!("cargo:warning=DEBUG: Build script starting...");
println!(
Expand Down Expand Up @@ -1473,13 +1491,7 @@ fn main() {
println!("cargo:rustc-link-lib=static=edge-impulse-sdk");

// Link against C++ standard library
if env::var("TARGET_LINUX_AARCH64").is_ok() {
// For aarch64 cross-compilation, use the ARM64 C++ standard library (dynamic)
println!("cargo:rustc-link-lib=dylib=stdc++");
} else {
// Use c++ for macOS and other platforms
println!("cargo:rustc-link-lib=c++");
}
link_with_standard_library();

// Link against prebuilt TensorFlow Lite libraries when using full TensorFlow Lite
if use_full_tflite {
Expand Down