How to link rustc_interface?

I am trying on rustc_interface. I finally succeeded on building my program, but when I executed it, it emits this error and fails to launch.

dyld: Library not loaded: @rpath/librustc_driver-e5b86ba3f1b435a6.dylib
  Referenced from: /Users/Dev/Workshop/rust-howto-examples/custom-compiler/target/debug/custom-compiler
  Reason: image not found

It seems I am missing something here. What am I supposed to do? I tried symlinking ./toolchains/nightly-x86_64-apple-darwin/lib/librustc_driver-e5b86ba3f1b435a6.dylib file beside th executable, but it didn't work.

You should either put ./toolchains/nightly-x86_64-apple-darwin/lib/ in the DYLD_LIBRARY_PATH env var, or run it by prefixing the command with rustup run nightly.

1 Like

This worked magically. Thanks.

1 Like