rust-lang / rust-lang/rust-bindgen
Problems bulding with msys2
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
I'm trying to build an app that needs to make use of libftdi, this makes use of bindgen to build the external library which is then static linked into the app, making it portable.
I am forced to use msys2/gnu rather than msvc.
I get the obscure error "Unable to find libclang: "the libclang shared library at C:\msys64\clang64\bin\libclang.dll could not be opened: LoadLibraryExW failed" But no indication what the cause of the failure actually is.
The file DOES exist in the location shown.
Directory: C:\msys64\clang64\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 04/12/2025 01:22 33602560 libclang.dll
My Cargo.toml contains
libftd2xx-ffi = { version = "~0.8.7", features = ["bindgen"] }
libftd2xx = { version = "0.33.1", features = ["static"] }
At first I got errors that bindgen could not find libclang.dll I fixed that by setting an environment variable in config.toml
I added LIBCLANG_PATH to my .cargo/config.toml
[target.x86_64-pc-windows-gnu]
linker = "C:\\msys64\\mingw64\\bin\\gcc.exe"
ar = "C:\\msys64\\mingw64\\bin\\ar.exe"
[env]
LIBCLANG_PATH = "C:\\msys64\\clang64\\bin"
The only other mentions I can find of this error are related to an embedded Rust project for ESP32. https://github.com/esp-rs/rust-build/issues/282, and they solve that by 'downgrading'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stated Cargo.toml dependencies and .cargo/config.toml, then reproduce the x86_64-pc-windows-gnu build using the reported MSYS2 paths. Investigate the LoadLibraryExW failure for C:\msys64\clang64\bin\libclang.dll rather than only checking that the file exists. Done means identifying the cause of the failed library load and documenting a reproducible resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100