How does cargo-run know where to look for linked libraries?


#1

I am trying to directly invoke an executable linked to openblas without using cargo run. Before I can do that, I need to put the path to the library in my LD_LIBRARY_PATH, which is target/debug/build/openblas-src-4eee8f5e0c02da2a/out/opt/OpenBLAS/lib, because otherwise the binary complains about missing links.

I understand that at compile-time openblas-src’s build.rs tells cargo to look for links due to the line println!("cargo:rustc-link-search={}", output.join("opt/OpenBLAS/lib").display());.

I don’t understand how the hash in openblas-src-4eee8f5e0c02da2a/ is created and where it is stored. How does cargo-run figure out that the links are located in openblas-src-4eee8f5e0c02da2a/?

I would like to write a wrapper script for my exectuable which automatically puts the right path into LD_LIBRARY_PATH and then runs the executable.