You are currently looking at an older section of the website.
Please check the new version of the site at for updated content.

wincent knowledge base

« Upgrading to Subversion 1.2.1 on Mac OS X 10.4.2 | Main | Upgrading to Subversion 1.3.0 »

July 16, 2005

Building Universal Binaries

If you want to build a Universal Binary that runs natively on both Panther (PowerPC) and Tiger (PowerPC and Intel) then you'll have to make some custom build settings. From reading the xcode-users mailing list and revising the Apple release notes and documentation a few things have become clear to me.

Most importantly, you'll need to set these custom, per-architecture build settings:

SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk

And a few things I've found out along the way:

(1) If you use a custom SDK (as is the case here) then the "Mac OS X Deployment Target" (MACOSX_DEPLOYMENT_TARGET) has no effect, because it is overridden by the SDK. Despite this postings from Apple employees indicate that you should set it anyway to the lowest version on which you wish to run (in this case 10.3). [Update: this is explained fairly well here.]

(2) If you choose a custom SDK in the "Get Info" dialog for your project then it will be overridden by your per-architecture SDKROOT settings. If you get a bunch of linker errors on the i386 build then it could be because you have an old, empty SDKROOT environment variable being passed to the linker; if you suspect this is the case you can set up a dummy shell script phase and inspect which environment variables are being set. (The solution in this case is to set an SDK, I'd recommend the 10.4 Universal SDK, in the "Get Info" window to prevent an empty SDKROOT environment variable from being passed to the linker.)

(3) You'll probably see warnings like this "ld: warning -prebind ignored because MACOSX_DEPLOYMENT_TARGET environment variable greater or equal to 10.4" when doing the i386 part of the build. You can suppress these by turning off prebinding in the Build Settings and adding the following only to the ppc build:

OTHER_LDFLAGS_ppc = -prebind

In this way you get prebinding on 10.3 (good) and not on 10.4 (also good) and no warnings during the build (very good).

(4) Finally, in some of my projects (but not all of them) I get i386 linker errors in debug builds unless I turn off ZeroLink. Not sure why these warnings appear in some projects but not others. Some Apple folk recommend not including the i386 architecture in your debug builds because you can't run a debug build on a machine other than the one on which it was built, but seeing as I want to use exactly the same xcodeproj file regardless of whether I am performing the build on a PowerPC or an Intel machine I want my debug builds to include both architectures.

Posted by wincent at July 16, 2005 09:59 AM