cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Cargo can't set rpath into library or binary

Open ruisv opened this issue 5 years ago • 4 comments

build.rs

println!("cargo:rustc-link-arg=-Wl,-rpath={}", &libdir);

I set rpath in this way but it didn't take effect. How to set rpath into library or binary?

Thank you for your reply.

ruisv avatar Oct 08 '21 12:10 ruisv

There is an rpath setting in the profiles you can set, does that help?

ehuss avatar Oct 08 '21 15:10 ehuss

There is an rpath setting in the profiles you can set, does that help?

When I use conda, there is an environment variable that stores the library path like $CONDA_PREFIX. If it is set in the configuration file, the environment variable cannot be automatically matched.

ruisv avatar Oct 13 '21 02:10 ruisv

The link arguments should be passed to the binary. Can you provide a reproduction or any other details to indicate what you've tried and why it doesn't appear to be working? If I try a simple binary with your example, I get:

objdump -x target/debug/foo | grep runpath
  RUNPATH              /home/eric/Temp

where that is a path I added in build.rs.

ehuss avatar Oct 22 '21 17:10 ehuss

Closing as there doesn't appear to be enough information here to move this forward. If the questions above could be answered, preferably with a full reproduction and set of steps, feel free to re-open.

ehuss avatar Sep 26 '23 20:09 ehuss