Cannot run the executable on a different computer

I compile it on my main computer and then I transfer it to a different computer and then I get this error message:

image

Inside my %userprofile%\.cargo\config.toml I have added stuff in:

# Windows 64 bit programs
[target.x86_64-pc-windows-msvc]
rustflags = [
	"-C", "link-arg=libvcruntime.lib"
]

# Windows 32 bit programs
[target.i686-pc-windows-msvc]
rustflags = [
	"-C", "link-arg=libvcruntime.lib"
]

When I try to compile it and transfer it to a different computer then I get this error message:

I believe the correct rustflags to statically link the VC++ runtime (on both targets) is:

rustflags = ["-C", "target-feature=+crt-static"]

Also, note that you can make a .cargo/config inside your project folder if you don't want this setting to apply to your entire machine.

1 Like

I only have this one piece of line inside:

%userprofile%\.cargo\config.toml and I now get the first error message.

Thanks for the tip but I may just want it to be applied globally

It should either look like this:

[build]
rustflags = ["-C", "target-feature=+crt-static"]

Or if you want it just to apply to Windows:

[target.'cfg(windows)']
rustflags = ["-C", "target-feature=+crt-static"]
1 Like