KyleMayes / clang-sys

Rust bindings for libclang.
Apache License 2.0
134 stars 69 forks source link

Tries to load libclang.dll from MinGW instead of native one on Windows #150

Closed RReverser closed 1 year ago

RReverser commented 1 year ago

I kept getting

thread 'main' panicked at 'Unable to find libclang: "the libclang shared library at C:\msys64\mingw64\bin\libclang.dll could not be opened: LoadLibraryExW failed"'

in another library that depends on clang-sys.

In the end I temporarily renamed that file to libclang_.dll, and it correctly picked up my C:\Program Files\LLVM\bin\libclang.dll instead.

I don't understand why it keeps trying to pick MinGW64 library when I'm building with a -msvc target, and C:\msys64\mingw64\bin is not even on my PATH but C:\Program Files\LLVM\bin that contains the correct DLL, is.

RReverser commented 1 year ago

FWIW when looking through issues the only relevant one I found https://github.com/KyleMayes/clang-sys/issues/74, but it seemed to be resolved long ago and said that clang-sys now does "the architecture detection for DLLs"... but then, I understand even less why MinGW DLL would be picked up instead of my regular one if it doesn't match the Rust target nor appears on my PATH :/

KyleMayes commented 1 year ago

The architecture detection from that issue is 32-bit vs 64-bit, not MinGW vs MSVC. I'll look into doing something similar for toolchain detection on Windows.

KyleMayes commented 1 year ago

I ended up just specifying which directory patterns are expected to be MSVC-compatible so that the MinGW directory pattern is excluded with an MSVC target. This should now be fixed on v1.5.1.

RReverser commented 1 year ago

Thanks.