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();
    }
}
posted @   develon  阅读(118)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· 分享4款.NET开源、免费、实用的商城系统
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
点击右上角即可分享
微信分享提示