How to generate statically linked executables?

Since Rust 1.19, you can statically link the C runtime (CRT) to avoid this very common situation on Windows:

The program can’t start because VCRUNTIME140.dll is missing from your
computer. Try reinstalling the program to fix this problem.

Add this to your .cargo/config file, using the appropriate target triple for your platform:

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

An alternative to editing .cargo/config is to pass -C target-feature=+crt-static to rustc by hand.

See also:

  • RFC

  • Pull Request

  • Cargo config documentation

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)