Cross compiling for a windows virtual m/c under macOS

I have rust installed on my intel Mac.
I have Windows 10 running on a Parallels virtual machine.
The windows 10 install says it's a 32 bit OS running on a 64 bit processor.

What toolchain should I use for my cargo build?

I tried x86_64-pc-windows-gnu but got a windows message saying that my exe was incompatible with the windows system I was running.

Indeed, you're building 64-bit binaries and trying to run them on a 32-bit OS.

Either install a 64-bit OS (since your VM is clearly capable of it), or use the i686-pc-windows-gnu toolchain instead.

The naming (i686 for 32-bit, and x86_64 for 64-bit) should probably have gone through some bikeshedding. (Not Rust's fault though, the nomenclature is pretty random everywhere).

Thanks for that.
I'll try install installing a 64 bit Windows first.

If I did use the i686 toolchain what linker would I need?

For cross compilation you'll need a cross-compile-capable GCC and its linker.

However, since you already have a VM, it may be much easier to compile in the VM. For Windows the preferred solution is to use Visual Studio and the -msvc toolchain that uses MSVC's linker.

1 Like

Thanks for the suggestion. I tried to download Visual Studio in my VM but sadly it won't run on my 32 bit windows.
The obvious answer seems to be to install a 64 bit version of windows but that's not really a path I want to follow. I'm on a tight budget and lacking storage for another VM.

As cross-compiling seems to work fine for x86_64-pc-windows-gnu I'll stick with that. It just means I can't test the exe on my own hardware.

I've now abandoned the idea of using a 64bit windows. I don't have enough storage to create another VM. (I also can't find the license key for my Windows 10 !)

I've tried i686-pc-windows-gnu but I get errors when linking - related to Unwind_Resume.

I've already spent too much time on this so I think I'll park the problem and concentrate on developing my rust skills while running on my Mac.

Thanks for your help.

I missed simple solution to my problem: I don't need to cross-compile at all for what I want to do!
I just installed rust in my Windows VM and I can compile and test easily!