Cross compiling on mac for windows

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 13:20:30

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/7708156/cross-compiling-on-mac-for-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!