static_vcruntime

Crates.iostatic_vcruntime
lib.rsstatic_vcruntime
version2.0.0
sourcesrc
created_at2021-03-23 10:41:21.394337
updated_at2022-04-20 14:23:21.880408
descriptionStatically link the VCRuntime when using the MSVC toolchain.
homepage
repositoryhttps://github.com/ChrisDenton/static_vcruntime
max_upload_size
id372551
size18,954
Chris Denton (ChrisDenton)

documentation

README

Statically link the VCRuntime when using the MSVC toolchain.

By default, Rust requires programs to deploy vcruntime140.dll (or equivalent) when redistributing binaries. This crate statically links the library instead.

Usage

Add this to your Cargo.toml:

[build-dependencies]
static_vcruntime = "2.0"

And in your build script:

fn main() {
    static_vcruntime::metabuild();
}

That is all. Then when you build a release binary, the runtime will be statically linked:

cargo build --release

Issues

If you have problems then you may need to clean the build directory before rebuilding:

cargo clean

If all else fails then, in the same directory as your Cargo.toml, create a folder called .cargo. In that folder create the file config.toml and add the following:

[target.'cfg(all(windows, target_env = "msvc"))']
rustflags = ["-C", "target-feature=+crt-static"]

This makes it easier to override the defaults.

Commit count: 25

cargo fmt