「Rust」- 场景及方案

静态编译

“cannot produce proc-macro for `crate` as the target `x86_64-unknown-linux-gnu` does not support these crate types” with +crt-static
rust – How to generate statically linked executables? – Stack Overflow

// 通过命令行专递参数构建

RUSTFLAGS="-C target-feature=+crt-static" cargo install --jobs 2 --path . --target x86_64-unknown-linux-gnu

// 或者,通过 Cargo.toml 文件:
...
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
...