Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross compiling on mac for windows

Can I compile on mac so it will produce a windows binary? bind with windows dlls? (I have a windows machine to copy them from) How can I do so? clang and gcc are the compilers I can use.

like image 631
Dani Avatar asked Oct 10 '11 03:10

Dani


2 Answers

These instructions will work on both MacOS and Linux, but I will provide them from a Mac perspective.

  1. Download Docker
  2. Add a Windows dockcross

If you don't know how to use docker then just download Kitematic (Links to an external site.).

From Kitematic you can simply click the "+New" button and get the dockcross image from the docker hub.

After the image downloads in Kitematic, click the "Docker CLI" button in the bottom left. This will open a new terminal window setup for the docker environment.

From that terminal window:

cd to the directory with the project you want to build then save a shellscript that will run the docker container and build the project:

  1. docker run --rm dockcross/windows-x86 > ./dockcross
  2. chmod +x ./dockcross
  3. ./dockcross make (assuming your project uses a makefile)

See the dockcross documentation for more examples and further guidance.

dockcross uses MXE, so you can pretty easily build most projects, but you may need to install additional MXE packages

like image 125
Brad Allred Avatar answered Sep 28 '22 02:09

Brad Allred


The MinGW's toolchain can be built on OSX or most other unix/unix-like operating systems.

Here's a link to the precompiled binaries: http://crossgcc.rts-software.org/doku.php?id=mingw-older-releases

It works fine on my PowerMac G5 and as keith.layne says there is also a solution for Intel Macs.

like image 41
Viktor Latypov Avatar answered Sep 28 '22 04:09

Viktor Latypov