// Taken from: https://rust-lang.github.io/rust-bindgen/library-usage.html use std::env; use std::path::PathBuf; fn main() { // Tell cargo to look for shared libraries in the specified directory // println!("cargo:rustc-link-search=/path/to/lib"); println!("cargo:rustc-link-lib=zint"); println!("cargo:rerun-if-changed=wrapper.h"); let bindings = bindgen::Builder::default() .header("wrapper.h") // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); }