2

How to specify an output file name dynamically via a command line for a library?

# something like this
cargo build --output-file-name "my_lib.so" # or .*dylib

Doing it via Cargo.toml or .cargo/config won't work for me.

Is it possible at all?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
mixtouku
  • 67
  • 1
  • 3
  • 1
    Rename the file after building? You probably can make something work with `cargo rustc` or `RUSTFLAGS`, but I'm not sure it's worth it. – Sven Marnach Aug 03 '20 at 11:28

1 Answers1

4

Edit:

See the following: https://doc.rust-lang.org/cargo/reference/cargo-targets.html#configuring-a-target which might help you specify the name of the final .so


The following parameter controls the output file name in rustc

https://doc.rust-lang.org/rustc/command-line-arguments.html#-o-filename-of-the-output

As Steve Marnach mentioned you can pass flags to rustc through several ways described here.

Alternatively you could have a post-build script using Philipp Oppermann's cargo-post tool and set it up to rename the output lib.

finnkauski
  • 169
  • 4