2

I'm working on a project in Rust on MacOS, with some additional C/Fortran dependencies. All my dependencies are installed in my Conda environment. Unfortunately, invoking cargo test yields a runtime failure, because it is unable to find libfortran.3.dylib:

$ cargo test
...
dyld: Library not loaded: @rpath/libgfortran.3.dylib
  Referenced from: /Users/user1/my_project/... 
  Reason: image not found
...

Setting LD_LIBRARY_PATH to point to the right place removes this issue:

$ LD_LIBRARY_PATH=$CONDA_PREFIX/lib cargo test
...
running 208 tests
test test1 .. ok
...

Is there a way to put that information in Cargo.toml so I don't have to explicitly modify the environment?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Jytug
  • 1,072
  • 2
  • 11
  • 29
  • 1
    Settings in `Cargo.toml` would apply to *everyone* who would ever want to compile the crate. It does not make sense to me to put something that is so very machine-specific into such a generic location. Rather, it seems like you should adapt your build process to correctly link the libraries you need (or set an rpath, etc.) – Shepmaster Oct 10 '17 at 14:56
  • How would I go about setting the `rpath` correctly then? My intention is to find a portable build process – Jytug Oct 10 '17 at 15:04
  • [Linking Rust application with a dynamic library not in the runtime linker search path](https://stackoverflow.com/q/40602708/155423) seems relevant. There's also https://stackoverflow.com/q/37017915/155423. – Shepmaster Oct 10 '17 at 15:08
  • 1
    I have gone through both of those answers. The problem I encountered is that apparently `cargo rustc` doesn't support the -C option – Jytug Oct 10 '17 at 15:37

0 Answers0