我正在尝试学习如何使用 bindgen。我正在关注文档(https://rust-lang.github.io/rust-bindgen/tutorial-3.html),并且我有以下代码链接到 C 库:
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rustc-link-lib=vulkan-1");
println!("cargo:rerun-if-changed=vulkan/vulkan.h");
let bindings = bindgen::Builder::default().header("vulkan/vulkan.h").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!");
}
但是当我跑步时cargo build
,我得到了note: LINK : fatal error LNK1181: cannot open input file 'vulkan-1.lib'
。我做错了什么?