mixtouku
mixtouku

Reputation: 117

How to specify the output file name of a library via the command line?

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?

Upvotes: 7

Views: 8163

Answers (1)

finnkauski
finnkauski

Reputation: 309

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.

Upvotes: 6

Related Questions