diff --git a/src/driver/sys/mod.rs b/src/driver/sys/mod.rs index 8261e2f..8138491 100644 --- a/src/driver/sys/mod.rs +++ b/src/driver/sys/mod.rs @@ -1,3 +1,5 @@ +use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; + #[cfg(feature = "cuda-11040")] mod sys_11040; #[cfg(feature = "cuda-11040")] @@ -62,9 +64,14 @@ pub unsafe fn lib() -> &'static Lib { static LIB: std::sync::OnceLock = std::sync::OnceLock::new(); LIB.get_or_init(|| { let lib_name = "cuda"; - let choices = [lib_name, "nvcuda"]; - for choice in choices { - if let Ok(lib) = Lib::new(libloading::library_filename(choice)) { + // See issue #296 + let choices = [ + std::format!("{DLL_PREFIX}{lib_name}{DLL_SUFFIX}"), + std::format!("{DLL_PREFIX}nvcuda{DLL_SUFFIX}"), + std::format!("{DLL_PREFIX}{lib_name}{DLL_SUFFIX}.1"), + ]; + for choice in choices.iter() { + if let Ok(lib) = Lib::new(choice) { return lib; } }