知识卡片
原生链接需要库名和搜索位置
链接原生库时需提供库名,必要时还需提供搜索路径。可用link属性,或让build.rs输出rustc-link-lib与rustc-link-search指令;后者可按目标环境选择。库文件名与格式依平台而变,构建脚本还应使输入、路径与工具版本可追踪。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 6. Beyond Standard Rust Linking logistics · 查看原书依据
cargo:rustc-link-lib instruction to cargo:6 // File build.rs fn main() { // An external library like `libcffi.a` is needed println!("cargo:rustc-link-lib=cffi"); } The latter option is more flexible, because the build script can examine its environment and behave differently depending on what it finds. In either case, the Rust build system is also likely to
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第6章《Linking logistics》(spine10;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch06.html;u175-ch06-008)。
- 结论依据:原文在“cargo:rustc-link-lib”附近的定义、例子或代码支撑本卡核心说明:链接原生库时需提供库名,必要时还需提供搜索路径。边界按已读前提解释;示例未执行。
- 原始内容:cargo:rustc-link-lib instruction to cargo:6 // File build.rs fn main() { // An external library like `libcffi.a` is needed println!("cargo:rustc-link-lib=cffi"); } The latter option is more flexible, because the build script can examine its environment and behave differently depending on what it finds. In either case, the Rust build system is also likely to