无法添加到依赖项的 rustc-link-search 路径
Unable to add to the rustc-link-search path of a dependency
我正在尝试使用 cassandra-rs which uses the DataStax CPP driver 构建一个测试应用程序。我正在使用 cargo 0.6.0 (ec9398e 2015-09-29) (built from git)
。
我的 DataStax 驱动程序不在 Cargo 查找的标准目录中。
我添加了一个指定 DataStax 驱动程序路径的构建脚本:
fn main() {
println!("cargo:rustc-link-search={}", "/path/to/dir/");
}
这是我的 Cargo.toml:
[package]
name = "castest"
version = "0.1.0"
build = "build.rs"
[dependencies]
cassandra="*"
但是cargo build --verbose
显示构建时没有包含额外的搜索目录
构建实际失败的包是 cql_bindgen,它是 cassandra-rs 的依赖项。在那个项目中有这个 build.rs:
fn main() {
println!("cargo:rustc-flags=-l dylib=crypto");
println!("cargo:rustc-flags=-l dylib=ssl");
println!("cargo:rustc-flags=-l dylib=stdc++");
println!("cargo:rustc-flags=-l dylib=uv");
println!("cargo:rustc-link-search={}", "/usr/lib/");
println!("cargo:rustc-link-search={}", "/usr/local/lib64");
println!("cargo:rustc-link-lib=static=cassandra_static");
}
如何在我的项目中添加额外的库或覆盖在依赖项目中设置的配置?
包的下游用户无法更改包的编译方式,除非 features 包公开。
当 link 连接到现有的本机库时,Cargo build script 用于帮助找到合适的库 link 到。
这里正确的解决方案是修复上游 crate (cql_bindgen) build.rs to allow end users to specify alternate paths to search within. One way of doing this is to use the option_env!
宏,类似于:
if let Some(datastax_dir) = option_env!("CQL_BINDGEN_DATASTAX_LIB_PATH") {
println!("cargo:rustc-link-search={}", datastax_dir);
}
当然,您可以 override the dependency 在迭代时使用本地版本以获得在本地工作的解决方案。
同时,您可以尝试将您的库安装在已搜索到的硬编码目录之一中。
我正在尝试使用 cassandra-rs which uses the DataStax CPP driver 构建一个测试应用程序。我正在使用 cargo 0.6.0 (ec9398e 2015-09-29) (built from git)
。
我的 DataStax 驱动程序不在 Cargo 查找的标准目录中。
我添加了一个指定 DataStax 驱动程序路径的构建脚本:
fn main() {
println!("cargo:rustc-link-search={}", "/path/to/dir/");
}
这是我的 Cargo.toml:
[package]
name = "castest"
version = "0.1.0"
build = "build.rs"
[dependencies]
cassandra="*"
但是cargo build --verbose
显示构建时没有包含额外的搜索目录
构建实际失败的包是 cql_bindgen,它是 cassandra-rs 的依赖项。在那个项目中有这个 build.rs:
fn main() {
println!("cargo:rustc-flags=-l dylib=crypto");
println!("cargo:rustc-flags=-l dylib=ssl");
println!("cargo:rustc-flags=-l dylib=stdc++");
println!("cargo:rustc-flags=-l dylib=uv");
println!("cargo:rustc-link-search={}", "/usr/lib/");
println!("cargo:rustc-link-search={}", "/usr/local/lib64");
println!("cargo:rustc-link-lib=static=cassandra_static");
}
如何在我的项目中添加额外的库或覆盖在依赖项目中设置的配置?
包的下游用户无法更改包的编译方式,除非 features 包公开。
当 link 连接到现有的本机库时,Cargo build script 用于帮助找到合适的库 link 到。
这里正确的解决方案是修复上游 crate (cql_bindgen) build.rs to allow end users to specify alternate paths to search within. One way of doing this is to use the option_env!
宏,类似于:
if let Some(datastax_dir) = option_env!("CQL_BINDGEN_DATASTAX_LIB_PATH") {
println!("cargo:rustc-link-search={}", datastax_dir);
}
当然,您可以 override the dependency 在迭代时使用本地版本以获得在本地工作的解决方案。
同时,您可以尝试将您的库安装在已搜索到的硬编码目录之一中。