rust-bindgen
rust-bindgen copied to clipboard
Windows keeps using MSVC, even when `CC` and `CXX` are set explicitly and empty `PATH`
nanodbc\nanodbc>set PATH="C:%HOMEPATH%\.cargo\bin"
nanodbc\nanodbc>set CC="%LIBCLANG_PATH%\clang.exe"
nanodbc\nanodbc>set CXX="%LIBCLANG_PATH%\clang++.exe"
nanodbc\nanodbc>%CC% --version
clang version 18.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
nanodbc\nanodbc>bindgen nanodbc.h -o bindings.rs
[omitted most output for brevity]
pe '__std_exception_data'\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\vcruntime_exception.h:39:13: error: must use 'struct' tag to refer to type '__std_exception_data'\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\vcruntime_exception.h:45:8: error: expected identifier or '('\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\exception:36:1: error: unknown type name 'namespace'\nfatal error: too many errors emitted, stopping now [-ferror-limit=]\n")
Same issue as this guy had 4 years ago #1844
Trying with the nuclear option:
:: clear all vars
nanodbc\nanodbc>for /f "usebackq delims==" %f in (`set`) do (set %f=)
nanodbc\nanodbc>set HOMEPATH :: specific to me
nanodbc\nanodbc>set LIBCLANG_PATH="C:\Program Files\LLVM\bin"
nanodbc\nanodbc>set PATH="C:%HOMEPATH%\.cargo\bin"
nanodbc\nanodbc>set CC="%LIBCLANG_PATH%\clang.exe"
nanodbc\nanodbc>set CXX="%LIBCLANG_PATH%\clang++.exe"
nanodbc\nanodbc>dir %LIBCLANG_PATH%\*clang.dll
Volume in drive C is OS
Volume Serial Number is D2B2-BE47
Directory of C:\Program Files\LLVM\bin
2024-06-19 03:23 AM 100,587,008 libclang.dll
1 File(s) 100,587,008 bytes
0 Dir(s) 19,601,973,248 bytes free
nanodbc\nanodbc>bindgen nanodbc.h -o bindings.rs
thread 'main' panicked at C:%HOMEPATH%\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.69.4\lib.rs:622: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
I don't have a way to debug this as I don't have a windows machine but the clang-sys docs mentions something about windows:
On Windows, running an executable that has been dynamically linked to libclang requires that libclang.dll can be found by the executable at runtime. See here for more information.
Yes, but %LIBCLANG_PATH%\libclang.dll is present.
maybe I misread the microsoft docs but it seems to imply that LIBCLANG_PATH should be in PATH as well. Is that the case?