Compiling from MacOS to Windows

Hi, I recently finished a quick project and I wanted to share it with my friends. The problem is that they all run Windows while I'm on a M1 Mac. I used the cargo build --target=x86_64-pc-windows-gnu command, but then I got 747 error messages. Here's one of them:

error[E0425]: cannot find function `_mm256_setr_m128i` in this scope
    --> /Users/oihandeshayes/.cargo/registry/src/
1698 | ...   u32x4x2_avx2::new(_mm256_setr_m128i(x.0[2].x, x.0[3].x)),
     |                         ^^^^^^^^^^^^^^^^^ not found in this scope

How can I compile successfully?

Cross compiling from MacOS to Windows can be hard. I’d suggest using Docker. Mount your project folder in a Windows container and compile it there.


I don't know why, but docker don't work on my system.

Hello again. I just wanted to say that after a lot of googling, I discover this command:

rustup target add x86_64-pc-windows-msvc

I used it and now I have only one error:

   Compiling guessing_game v0.1.0 (/Users/oihandeshayes/Desktop/myProjects/guessing_game)
warning: unused variable: `other`
  --> src/
38 |             other => {
   |             ^^^^^ help: if this is intentional, prefix it with an underscore: `_other`
   = note: `#[warn(unused_variables)]` on by default

error: linker `link.exe` not found
  = note: No such file or directory (os error 2)

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

note: VS Code is a different product, and is not sufficient.

warning: `guessing_game` (bin "guessing_game") generated 1 warning
error: could not compile `guessing_game` (bin "guessing_game") due to previous error; 1 warning emitted

I get that the necessary linker is missing, but where could I get it?

The message even says where: link.exe is part of Visual Studio (including free Build Tools for Visual Studio).

But these are only usable on Windows thus you need either docker or wine.

Ok, but what is the difference between x86_64-pc-windows-msvc and x86_64-pc-windows-gnu? Maybe that could compile.

Difference between mvsc and gnu are the used buildtools. Mvsc uses Visual Studio build tools and gnu uses mingw.

You’ll need docker though. Another less efficient option would be a VM like Virtualbox.

1 Like

Docker for macOS and Windows runs Linux inside a VM for you. As such it is exactly as efficient as using something like Virtualbox.

Docker would be good, but every time I try a docker command it prints this error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. 
Is the docker daemon running?

EDIT: The docker commands now work, and I'v tried the cross project, but I now get this error:

Unable to find image '' locally
0.2.5: Pulling from cross-rs/x86_64-pc-windows-gnu
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See 'docker run --help'

while using the cross build --target x86_64-pc-windows-gnu command.

What docker image would you recommend to run windows, if cross don't work?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.