Cargo can be configured by adding a file in .cargo/config.toml
.
Notable settings
crate-type
defines what kind of library or binary the Rust compiler should generate when building the crate.
Options include:
crate-type options | Description |
---|---|
bin | An executable is produces from main.rs |
lib | An alias for “compiler recommended” library (one of the options below), generated from lib.rs |
dylib | Dynamic Rust library. (.so on Linux, .dylib on Mac, and .dll on Windows) |
staticlib | A static system library that will not be linked to other libraries. (.a on most filesystems, .lib on Windows MSVC). Recommended when linking Rust code to a non-Rust application |
cydlib | C-compatible dynamic library, to load the binary from another language. Strips most Rust-specific metadata for consumption by non-Rust application |
rlib | A “Rust lbrary” that can be interpreted by the compiler for future linkage. Also an intermediate artifact in generating a staticlib |
proc-macro | Used to export procedural macros. Compiles to the same target as the compiler used, and not for the target program. |
Can be stacked.