How to override the linking path to a native lib


#1

I’m using the rust lib GSL, which links to the native .so lib libgsl.so. Originally there has already an installed version of libgsl in /usr/lib, however it’s too old and cannot work.

So I try to install my own newer version in my own path $HOME/root/usr/lib/.

But how can I tell cargo to link to the new one, instead of the old one?

I’v tried to modify the .cargo/config as

[x86_64-unknown-linux-gnu]
rustc-link-search = ["/home/blablabla/root/usr/lib"]

according to my search, but it does not work.

It seems that rustc can accept -L <path> parameter, but cargo command does not work.

Well, finally I found a solution:
just create a soft link to the .so file in .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib


#2

The GSL wrapper depends on pkg-config-rs, and doesn’t seem to be configurable: