Skip to content

Commit

Permalink
fix: join load-dynamic path on executable dir
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Apr 15, 2023
1 parent db3623c commit 06b945a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ lazy_static! {
pub(crate) static ref G_ORT_LIB: Arc<Mutex<AtomicPtr<libloading::Library>>> = {
unsafe {
// resolve path relative to executable
let absolute_path = std::env::current_exe().expect("could not get current executable path").join(&**G_ORT_DYLIB_PATH);
let path: std::path::PathBuf = (&**G_ORT_DYLIB_PATH).into();
let absolute_path = if path.is_absolute() {
path
} else {
std::env::current_exe().expect("could not get current executable path").parent().unwrap().join(path)
};
let lib = libloading::Library::new(&absolute_path).unwrap_or_else(|e| panic!("could not load the library at `{}`: {e:?}", absolute_path.display()));
Arc::new(Mutex::new(AtomicPtr::new(Box::leak(Box::new(lib)) as *mut _)))
}
Expand Down

0 comments on commit 06b945a

Please sign in to comment.