Notes on OS X

Richard W.M. Jones rjones at redhat.com
Sun Feb 8 16:07:21 UTC 2009


Since I was bored this morning, I took a look at the feasibility of
cross-compiling to OS X as well.  Compiling Gtk programs from a single
source tree for the three major platforms (Linux, Windows, Mac OS X)
with just a handful of commands is ... compelling, isn't it?

Here are some notes.

Compiler
----------------------------------------------------------------------

This guy has built a cross-compiler for Darwin which seems like a
decent starting point:

http://ranger.befunk.com/fink/darwin-cross/
http://ranger.befunk.com/fink/darwin-cross/SRPMS/

I looked at the gcc 4.0, headers and odcc tools packages from the
above link.

His GCC package is a straightforward recompile of Apple's modified GCC
from here:

http://www.opensource.apple.com/darwinsource/tarballs/other/

It is built as a cross-compiler for two targets (i386-apple-darwin8
and powerpc-apple-darwin8), with four compiler front-ends built for
each target (C, C++, Objective C and Objective C++).

Header files are supplied by another Apple package.  (I can't find a
direct link to these on Apple's site).  They are distributed under
APSL 2.0 license which is OK for Fedora but not GPL compatible.

Tools
----------------------------------------------------------------------

odcctools is a project to extend Darwin cctools build system.
Includes assembler and static linker, and various tools to examine
Mach-O and fat binaries.

http://odcctools.darwinports.com/

The darwin-cross project cross-compiles these using ordinary autoconf
techniques.

Why doesn't he package binutils?

What about a dynamic linker?  Apple's is called "dyld" and the dynamic
libraries have the extension ".dylib".  dyld is released under the
APSL (http://www.opensource.apple.com/darwinsource/tarballs/apsl/dyld-97.1.tar.gz).

Libraries
----------------------------------------------------------------------

libc?  glibc?  As on Windows, we have headers and so we don't need an
actual libc.

Apple supply various other libraries here, but we'd have to find out
what changes they had made and what the implications are:

http://www.opensource.apple.com/darwinsource/tarballs/other/

Gtk+ for Mac OS X
----------------------------------------------------------------------

Gtk+ for Mac OS X is a commercially-sponsored project to produce a
native port of Gtk+ to OS X.  This means it uses Quartz and doesn't
require X11 at runtime (but it doesn't use native widgets).  Another
good thing about this project is they are pushing their changes back
upstream into Gtk.

http://developer.imendio.com/projects/gtk-macosx/

Here are (non-cross) build instructions:

http://live.gnome.org/GTK%2B/OSX/BuildInstructions

There is also a separate "integration library" which provides some
extra APIs for making applications more native to OS X, and to support
special features like OS X preferences, menu bars, etc.

http://live.gnome.org/GTK%2B/OSX/Integration

They also support pkg-config as a build framework:

http://live.gnome.org/GTK%2B/OSX/Framework

Unfortunately they've gone and used their own build tool (so close and
yet so far!)

Emulation
----------------------------------------------------------------------

There is no way of running or emulating Mac OS X binaries on Fedora
(as with Wine / Windows).  Even virtualizing OS X itself is a
potential minefield.

----------------------------------------------------------------------

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/



More information about the mingw mailing list