How to Compile for OS X in Linux or Windows?

2019-01-04 08:25发布

I would like to port my C/C++ apps to OS X.

I don't have a Mac, but I have Linux and Windows. Is there any tool for this?

11条回答
Luminary・发光体
2楼-- · 2019-01-04 08:48

There are a few cross-compiler setups, but nearly all of them are meant for distcc-style distributed compiling. To my knowledge there is no way to directly target the Mac platform without actually having a Mac. The closest you can get without resorting to QT or wxWidgets is OpenStep with GNUStep or similar, but that's not a true Cocoa platform, just very close.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-04 08:49

There appears to be some scripts that have been written to help get you set up cross compiling for the Mac; I can't say how good they are, or how applicable to your project. In the documentation, they refer to these instructions for cross-compiling for 10.4, and these ones for cross compiling for 10.5; those instructions may be more helpful than the script, depending on how well the script fits your needs.

If your program is free or open source software, then you may wish instead to create a MacPorts portfile (documentation here), and allow your users to build your program using MacPorts; that is generally the preferred way to install portable free or open source software on Mac OS X. MacPorts has been known to run on Linux in the past, so it may be possible to develop and test your Portfile on Linux (though it will obviously need to be tested on a Mac).

查看更多
欢心
4楼-- · 2019-01-04 08:51

For Linux, there is a prebuilt GCC cross-compiler (from publicly available Apple's modified GCC sources).

https://launchpad.net/~flosoft/+archive/cross-apple

Update for 2015

  1. After so many years, the industry-standard IDE now supports OSX/iOS/Android.

http://channel9.msdn.com/Events/Visual-Studio/Connect-event-2014/311

  1. Embarcadero's RadStudio also supports building OSX/iOS/Android apps on Windows.

  2. This answer by Thomas also provides a cross-compilation tool.

For all these options you still need a real mac/i-device to test the application.

查看更多
再贱就再见
5楼-- · 2019-01-04 08:53

I have created a project called OSXCross which aims to target OS X (10.4-10.9) from Linux.

It currently supports clang 3.2 up to 3.8 (trunk) (you can use your dist's clang).
In addition you can build an up-to-date vanilla GCC as well (4.6+).

LTO works as well, for both, clang and GCC.

Currently using cctools-870 with ld64-242.

https://github.com/tpoechtrager/osxcross

查看更多
霸刀☆藐视天下
6楼-- · 2019-01-04 08:53

You will definitely need OS X somehow. Even if you don't own a Mac, you can still try some alternatives.

查看更多
登录 后发表回答