Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Compile for OS X in Linux or Windows?

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?

like image 418
Unknown Avatar asked Mar 29 '09 01:03

Unknown


People also ask

Can GCC compile for Mac?

Often times, you need c or gcc compiler to compile open source projects in Mac OS X. The problem is Mac OS X doesn't install the gcc compiler by default. In terminal, type “ gcc “, you will get message “command not found”.

Can you compile Windows programs on Linux?

mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32 , for example.

Why is OS X better than Linux?

Unlike Linux, which is rarely running on hardware that it was meant to be paired with, macOS is always running on hardware that was built for it. Nearly every component inside of a Mac computer was designed and built by Apple. And the OS running on that hardware was also built by Apple.


2 Answers

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.

like image 71
Viktor Latypov Avatar answered Sep 30 '22 13:09

Viktor Latypov


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

like image 41
Thomas Avatar answered Sep 30 '22 11:09

Thomas