Cross Compiling


#1

Hi folks,

I’m really interested in being able to output a bunch of different binaries for a small tool I’m building with Rust.

Compiling for a Windows environment (I develop on Mac), seems to be a challenge. My thought is to run a virtual machine with Windows and compile there, but that seems like a sledgehammer to crack a nut!

Anyone point me in a better direction?


#2

The basic rule of thumb in cross compilation for Rust right now is “If C/C++ can do it so can Rust”. The problem for compiling from Mac to Windows, for example, is that OSX doesn’t ship a linker by default which can target Windows, nor does it provide the system libraries that Windows has.

If you have a linker and system libraries for the target, however, it should just be a cargo build --target foo away.