I'm new to Rust development under Windows.
I'm trying to bindgen a library, libk4a
, on both windows and linux.On linux it is installed as libk4a
, under the usual places, /usr/local/include/k4a/k4a.h
and /usr/local/lib/libk4a.so
.
I've followed the bindgen book's example and have made a wrapper.h
to pass to build.rs
, which is simply:
#include <k4a/k4a.h>
This works fine under linux with the build.rs
setting of
println!("cargo:rustc-link-lib=k4a");
On windows, the dll is under C:\Program Files\Azure Kinect SDK v1.3.0\sdk\windows-desktop\amd64\release\bin\
and the header at C:\Program Files\Azure Kinect SDK v1.3.0\sdk\include\k4a\k4a.h
While I'm able to run bindgen on its own with
bindgen wrapper.h -- -I "C:\Program Files\Azure Kinect SDK v1.3.0\sdk\include"
If it try to add the include path in my build.rs as this previous answer suggests:
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg("-I \"C:\\Program Files\\Azure Kinect SDK v1.3.0\\sdk\\include\"")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
I still get the error saying it cannot find the header file:
wrapper.h:1:10: fatal error: 'k4a/k4a.h' file not found
wrapper.h:1:10: fatal error: 'k4a/k4a.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:11:20
Am I missing a place to add something to the include path? Should k4a/k4a.h
be on my path somewhere? Or do I have a typo in my config? I'm not sure why it works with raw bindgen
on the command line, but not build.rs
.