Cross-compiling to Windows : Do the following instructions also apply for Windows (with MingW)

Or is this only for cross-compiling from Mac OS to Linux?

Using these two, we can compile a program in a Mac that will run on that Linux like this:

crystal build --cross-compile --target "x86_64-unknown-linux-gnu"
This will generate a .o (Object file) and will print a line with a command to execute on the system we are trying to cross-compile to. For example:

cc your_program.o -o your_program -lpcre -lrt -lm -lgc -lunwind

The host platform doesn’t matter. As long as the compiler runs, it can cross-compile to any supported target platform.

MingW is not supported though (ref Build with Mingw-w64 · Issue #6170 · crystal-lang/crystal · GitHub).
Currently only native Windows is available via MSVC.

1 Like