I'm building a small Rust command-line tool that needs to use services from a specific third-party C++ DLL that I know will be installed at a specific location. Because this library is not mine, I am not in control of any of the following:
- where the DLL is installed (on Mac, it is in
- that is is a DLL and not a static library
- that the interfaces to the DLL are in C++
- the name of the DLL (which does not contain the
I'm having a bear of a time coming up with a
build.rs script that will find it and link to it appropriately.
I've gotten far enough that I can get
cargo build to succeed, but I but both
cargo test or
cargo run fail with message similar to the following:
dyld: Library not loaded: @rpath/MyMagicLibrary.dylib Reference from: /Users/scouten/my/repo/target/debug/deps/appname-deadbeefdeadbeef Reason: image not found
I was able to get as far as building successfully by sym-linking the DLL into
OUT_DIR, but this apparently baked in a reference to
@rpath which becomes invalid at subsequent steps.
I'm currently testing on Mac OS, but I expect to have similar issues on an upcoming Windows build.
What tricks are available for me to access this DLL?
I've been wrestling with build failures for hours and I'm running out of ideas.