rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.4k stars 691 forks source link

Thread panicking at bindgen .Err state unable to found libclang.dll but it available on the path variable #2831

Closed biplab5464 closed 4 months ago

biplab5464 commented 4 months ago

Original issue here

i was asked to post the issue here

PS D:\Rust\rust_project\fsp_rs> cargo run
warning: unused manifest key: dependencies.winfsp.feature
   Compiling winfsp-sys v0.2.2+winfsp-2.0
error: failed to run custom build command for `winfsp-sys v0.2.2+winfsp-2.0`

Caused by:
  process didn't exit successfully: `D:\Rust\rust_project\fsp_rs\target\debug\build\winfsp-sys-156959fd134dac13\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-search=C:\Users\BIPALB\.cargo\registry\src\index.crates.io-6f17d22bba15001f\winfsp-sys-0.2.2+winfsp-2.0\winfsp/lib
  cargo:rustc-link-lib=dylib=delayimp
  cargo:rustc-link-lib=dylib=winfsp-x64
  cargo:rustc-link-arg=/DELAYLOAD:winfsp-x64.dll
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

  --- stderr
  thread 'main' panicked at C:\Users\BIPALB\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.68.1\lib.rs:611:31:
  Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

PS D:\Rust\rust_project\fsp_rs> clang --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\Program Files\LLVM\bin

PS D:\Rust\rust_project\fsp_rs> cd D:\"Program Files"\LLVM\bin

PS D:\Program Files\LLVM\bin> dir | findstr libclang.dll 
-a----        02-03-2018  06.59 PM       58562048 libclang.dll

I am unable to compile this from last 3 days i also went thought code found that that it was mentioned that it used clang_6_0 so i also downgraded to clang c and still facing this issue

#inside bindgen/Cargo.toml
clang-sys = { version = "1", features = ["clang_6_0"] }

can you please help

pvdrz commented 4 months ago

As stated in the readme, you can specify the path of the libclang library using environment variables: https://github.com/KyleMayes/clang-sys#environment-variables

biplab5464 commented 4 months ago

Thank you for the help