Run tests that depend on shared library


I found this issue about usage of shared libraries for cargo test and cargo run.

Also I found that it is possible to set environment variable during build via:


But looks like these environment variables was used only during cargo build,
not cargo test.
Is any work around, may be set rpath for tests somehow?

I use only Linux, so any linux specific aswers are fine.
Also I don’t want to add env variable to .bashrc, because of I need to add CI script,
also configure all developers machines. So I am looking some solution to fix it inside code base.

Note: I have no problems with cargo build, I used println!(rustc-link-search for it.

#2 script can print cargo:rustc-link-search=native=/path/to3rdparty/libs, and this should set up paths in a more portable way.


Sorry for misunderstanding. I already used rustc-link-search.
The question is not in cargo build it is about cargo test and cargo run.