Linking Rust application with a dynamic library not in the runtime linker search path

前端 未结 2 743
滥情空心
滥情空心 2020-12-01 13:23

I have a shared library that I\'d like to dynamically link into several separate binary Cargo applications. I include its location in the linker using the -- -L /path

2条回答
  •  一整个雨季
    2020-12-01 13:45

    Adding to what Shepmaster said (apparently I don't have enough reputation to comment): I'm not sure when this feature was added, but as of at least Rust 1.20, you can achieve the same effect by setting the environment variable RUSTFLAGS:

    $ RUSTFLAGS="-C link-args=-Wl,-rpath,/the/lib/path" cargo build
    

    This can be more convenient than the cargo rustc option if, for instance, you're using build scripts that just invoke cargo build.

提交回复
热议问题