我有两个独立创建的
libsomelibrary.rlib
文件,分别位于 /path/to/deps/debug/
和 /path/to/deps/release/
目录下。同时我有一个项目在 /path/to/myproject/
目录下,需要静态链接到libsomelibrary.rlib
。
如何在 Cargo.toml (或其他地方)中指定对这些 .rlib 的引用?
我已经尝试在 Cargo.toml 中的 [dependencies]
下添加 somelibrary
,并使用 build.rs 指定搜索路径和文件名:
println!("cargo:rustc-link-lib=static=somelib");
println!("cargo:rustc-link-search=/path/to/deps/debug/");
然后在 Cargo.toml 文件中:
[package]
build = "build.rs"
links = "somelibrary"
但我仍然遇到链接错误。