Universal Binaries without XCode
OS X inherited fat binary technology from NextStep. Back in the
NextStep days, the incantation was easy, you'd just add
-arch i386 -arch
ppc to all your compilation/linking/library commands and you'd be all
With OS X, Apple made it "even easier" — just a check box in XCode. And for
projects that still use things like
Makefiles, they give you
detailed instructions for Building
an Open Source Universal Binary. Great right? Not so much, because the
those instructions essentially tell you how to make XCode manage the whole
build, which is, frankly, nuts.
If you try to go old school and pass
-arch i386 -arch ppc to
gcc, all seems fine until you try to link, and which point it dies
horribly. Turns out that the "standard" developer libraries are thin, not fat.
So, to link your program, you need to pass
/Developer/SDKs/MacOSX10.4u.sdk to the linker to have it find some
libraries with the proper amount of universal goodness. For a C++ project, the
relevant incantation is
g++ -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc
Why didn't they just say that? Maybe they were too embarrassed...