Is there a way to set -rpath-link to cargo


Hello, currently I try to compile against a c library which isn’t in the standard folder so I need to set a -rpath-link however I didn’t find anything in the docs, is there any way by setting it?


You can specify arbitrary linker flags via:

  1. #[link_args = "..."] right in sources, but it’s unfortunately gated and thus not for stable
  2. -C link-args="...", but that’s command line for compiler, which Cargo seems to be unable to set ATM.


Bringing this thread back to life! :slight_smile: I’m working with a vendor SDK for embedded linux and this is a requirement.
If anyone is familiar with nvidia jetsons and or Drive PX systems or have used Rust with an Nvidia sdk in a cross compilation environment then I’d be happy to learn about any work arounds.


Ok, just for future searches. At the current time I was only able to make this work using the RUSTFLAGS environment variable to specify multiple -C linker-flag=-Wl,-rpath-link,/foo options.

It would be super to be able to emit this via my build script instead.