Skip to content

Commit

Permalink
Prioritize loading dll in the directory containing libclang.dll on Wi…
Browse files Browse the repository at this point in the history
…ndows (KyleMayes#187)
  • Loading branch information
taks committed Jul 31, 2024
1 parent e4c9b7e commit 52ff133
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,19 @@ https://rust-lang.github.io/rust-bindgen/requirements.html
let path = directory.join(filename);

unsafe {
let library = libloading::Library::new(&path).map_err(|e| {
#[cfg(target_os = "windows")]
// Prioritize loading dll in the directory containing libclang.dll
let library =
libloading::os::windows::Library::load_with_flags(
&path,
libloading::os::windows::LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
libloading::os::windows::LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)
.map(From::from);

#[cfg(not(target_os = "windows"))]
let library = libloading::Library::new(&path);

let library = library.map_err(|e| {
format!(
"the `libclang` shared library at {} could not be opened: {}",
path.display(),
Expand Down

0 comments on commit 52ff133

Please sign in to comment.