Fabrício Dematte
Fabrício Dematte

Reputation: 21

Openvino library runtime conflict in cargo workspace

I think I have a linker conflict happening in my cargo workspace. Some context:

My workspace consists of 3 crates:

engine_rs uses opencv-rs and openvino-rs with latest versions.

engine C++ code uses system opencv and a older version openvino. I have shared object files for this openvino version locally inside this crate under {cmake_src_dir}/external/openvino/lib

In ffi_test when I run test separately, commenting code for each engine, it works :thumbsup_tone1: . The issue happens when I run both engines at the same time, and I need to do this to compare outputs:

Error: openvino_finder: OpenVINO version is too old (see https://github.com/intel/openvino-rs/issues/143): 2022.1.0-7019-cdb9bec7210-releases/2022/1")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test rs_engine_test ... FAILED
test cpp_engine_test ... ok

Rust engine_rs is trying to use the older openvino lib that comes in engine crate, even though they are separate crates. I have openvino-rs with runtime-linking enabled. That's the furthest I got

engine build.rs:

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
fn linux_x86_64_main() {
    let cpp_engine = cmake::Config::new("./engine")
        .no_build_target(true) // Skip `make install`
        .build();

    println!("cargo:warning=engine output:{}", cpp_engine.display());
    println!("cargo:rustc-link-search={}/build", cpp_engine.display());
    println!("cargo:rustc-link-lib=engine");

    println!("cargo:rustc-link-search=native=fid_engine/engine/external/openvino/lib");
    println!("cargo:rustc-link-lib=dylib=openvino");
    println!("cargo:rustc-link-lib=dylib=tbb");

    println!("cargo:rerun-if-changed=engine/CMakeLists.txt");
}

engine_rs build.rs:

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
fn linux_x86_64_main() {
    println!("cargo:rustc-link-search=native=/usr/lib");
    println!("cargo:rustc-link-lib=openvino_c");
    println!("cargo:rustc-link-lib=openvino");
    println!("cargo:rustc-link-lib=tbb");
    println!("cargo:rustc-link-lib=opencv_core");
    println!("cargo:rustc-link-lib=opencv_dnn");
    println!("cargo:rustc-link-lib=opencv_imgproc");
    println!("cargo:rustc-link-lib=opencv_imgcodecs");
}

I need to run both engines in the same test so I can compare the output. How can I proceed here?

Upvotes: 1

Views: 54

Answers (1)

Fabrício Dematte
Fabrício Dematte

Reputation: 21

Apparently this is an open issue in cargo 7880

Upvotes: 1

Related Questions