#windows #msvc #vcruntime

no-std static_vcruntime

Statically link the VCRuntime when using the MSVC toolchain

10 stable releases

Uses new Rust 2021

2.0.0 Apr 20, 2022
1.5.1 Apr 23, 2021
1.1.0 Mar 30, 2021

#54 in Build Utils

Download history 171/week @ 2022-03-16 55/week @ 2022-03-23 85/week @ 2022-03-30 47/week @ 2022-04-06 59/week @ 2022-04-13 95/week @ 2022-04-20 194/week @ 2022-04-27 214/week @ 2022-05-04 305/week @ 2022-05-11 326/week @ 2022-05-18 300/week @ 2022-05-25 243/week @ 2022-06-01 259/week @ 2022-06-08 227/week @ 2022-06-15 159/week @ 2022-06-22 128/week @ 2022-06-29

808 downloads per month

MIT OR Apache-2.0 OR Zlib

8KB

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.

No runtime deps