Help targetting 32-bit windows

i'm writting an application that must run on 32 bits windows, but when i test it on windows 7 service pack 1, i get the error that VCRUNTIME140.dll is lacking, is there a way to statically link it?
currently i'm running this comand for compilation "cargo build --target=i686-pc-windows-msvc --release" , and in my cargo.toml i got this
"
[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static", "-Zunstable-options"]
"

Any program compiled with the visual studio compiler toolchain is expected to distribute the C runtime of the respective toolchain version themself. This is true for C/C++ programs and also for Rust when using the msvc variant. I don't think there is a way to statically link it. The distribution is done in the form of the "Visual C++ Redistributable" package. If you look at the list of installed programs, you will likely find multiple versions of this. Each one installed by the installer of a program requiring it.

You need to install the MSVC runtime on the target machine:

There is. You need to add libvcruntime.lib to statically link it.

To do this you need to create a folder called .cargo. It should be placed in the root of your project. Add a file called config.toml in this folder.

[target.i686-pc-windows-msvc]
rustflags = ["-C", "link-arg=libvcruntime.lib"]

Note that this is put in .cargo\config.toml and NOT cargo.toml. Sorry for shouting there but it's so easy to confuse the two.

Alternatively if you do not want to statically link you should have all the necessary files on your system to redistribute. Though finding them can be a bit tricky. In the start menu there should be a special command prompt called "x86 Native Tools". Run that and enter:

echo %VCToolsRedistDir%

It'll print out the directory with installers for different systems. If you don't want to have to run an installer you can also just copy the dll to you application's folder. The dll should be in a folder named something like %VCToolsRedistDir%x86\Microsoft.VC142.CRT (again, use the native tools prompt to get the actual directory).

It should be noted that Microsoft recommend using the installer for "servicing" reasons when dynamic linking. However, judging by the number of applications on my system that ship vcruntime140.dll, I'm guess many people ignore that advice.

thanks for your help, i ended up compiling on a 64bit linux machine with MinGW with "cargo build --target=i686-pc-windows-gnu --release", and worked perfectly on a 32bit windows 7 machine.

You can use i686-pc-windows-gnu on Windows too.