Skip to content

Commit

Permalink
fix: bundle libonnxruntime in rlib/staticlib builds (#215)
Browse files Browse the repository at this point in the history
Fixes #214.
  • Loading branch information
cagnolone authored Jun 21, 2024
1 parent c64b8ea commit 882f657
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ort-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,15 @@ fn real_main(link: bool) {

if link {
if needs_link {
println!("cargo:rustc-link-lib=onnxruntime");
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let static_lib_file_name = if target_os.contains("windows") { "onnxruntime.lib" } else { "libonnxruntime.a" };

let static_lib_path = lib_dir.join(static_lib_file_name);
if static_lib_path.exists() {
println!("cargo:rustc-link-lib=static=onnxruntime");
} else {
println!("cargo:rustc-link-lib=onnxruntime");
}
println!("cargo:rustc-link-search=native={}", lib_dir.display());
}

Expand Down

0 comments on commit 882f657

Please sign in to comment.