Cargo.toml
[package]
name = "static_link"
version = "0.1.0"
authors = ["develon <develon@qq.com>"]
edition = "2018"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
build.rs
fn main() {
// println!("cargo:rustc-link-search={}", std::env::var("LIB_PATH").expect("请指定环境变量 LIB_PATH"));
println!("cargo:rustc-link-search=clang/build/Debug");
}
main.rs
#[link(name = "libjt", kind = "static")]
extern {
fn just_test();
}
fn main() {
unsafe {
just_test();
}
}