Build 64bit exe on 32bit windows?


#1

Note: I can build 32 binary in my setup without problems.
Now I need to build 64bit binary.

I tried:

c:\Program Files\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
cargo build --target=x86_64-pc-windows-msvc

and it reports that link.exe failed,
= note: msvcrt.lib(chkstk.obj) : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’

The strange thing, that when it show link.exe arguments I see many directories with Useres\\IEUser\\.rustup\\toolchains\\stable-i686-pc-windows-msvc.

Any hints to help build 64bit application on 32bit windows?

Update: looks like the problem not in my crate but in ws2_32-sys, kernel-sys and so on,
link failed about them.


#2

When you cross compile, it has to build build scripts for the host platform, in your case this is i686-pc-windows-msvc. However this conflicts with your vcvars which configures the environment for building x86_64 stuff only. Basically if you want to cross compile between arches with msvc you cannot use vcvars. Only by letting rustc autodetect VC++ will this scenario function.

At this point I have to wonder why you are using 32bit Windows in the first place. CPUs from both Intel and AMD have been 64bit for over a decade so it’s really rather strange for anyone to be using 32bit Windows still.


#3

@retep998

At this point I have to wonder why you are using 32bit Windows in the first place. CPUs from both Intel and AMD have been 64bit for over a decade so it’s really rather strange for anyone to be using 32bit Windows still.

Because of Microsoft provide available VirtualBox image with installed Windows 7 (target for me),
and unfortunately this is 32bit windows, and I can not find already installed Windows 7 64bit
into virtualbox image anywere in the Internet.


#4

@retep998

But if not set any “vars” cargo build report that link.exe not found and failed :frowning:


#5

Congratulations, you’re now in hell. Although rust definitely should be able to find link.exe considering you’re using VC++ 14 which rustc definitely has autodetection support for. However I never actually tested targeting 64bit on 32bit Windows so there might be some funky bugs… guess I’ll have to get a 32bit windows VM one of these days and find out.