rust - Unable to add to the rustc-link-search path of a dependency -
i trying build test app using cassandra-rs uses datastax cpp driver. using cargo 0.6.0 (ec9398e 2015-09-29) (built git)
.
my datastax driver not located in standard directories cargo looks in.
i added build script specifying path datastax driver:
fn main() { println!("cargo:rustc-link-search={}", "/path/to/dir/"); }
here cargo.toml:
[package] name = "castest" version = "0.1.0" build = "build.rs" [dependencies] cassandra="*"
but cargo build --verbose
shows additional search directory not included when building.
the package build failing on cql_bindgen dependency of cassandra-rs. in project there 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"); }
how can add additional libraries or otherwise override configuration in project set in dependent projects?
a downstream user of crate cannot make changes how crate compiled, other features crate exposes.
when linking existing native libraries, cargo build script used find appropriate libraries link to.
the correct solution here fix upstream crate (cql_bindgen) build.rs allow end users specify alternate paths search within. 1 way of doing use option_env!
macro, like:
if let some(datastax_dir) = option_env!("cql_bindgen_datastax_lib_path") { println!("cargo:rustc-link-search={}", datastax_dir); }
of course, can override dependency local version iterate solution works locally.
in mean time, can try installing library in 1 of hard-coded directories searched.
Comments
Post a Comment