In article <11b99t22pk6lo36 DeleteThis @corp.supernews.com>,
William McBrine <wmcbrine DeleteThis @covad.net> wrote:
> They say all you need to do to build fat binaries in Xcode is check a
> box. However, I have some Unix programs that I build with "make" on the
> command line, and I'm having a lot more trouble. The programs build OK
> for native PPC. And the object code files build just fine with "-arch
> i386" (or even "-arch ppc -arch i386"); but I can't for the life of me
> get them to link. I have Xcode 2.1 and the Universal SDK installed. I've
> tried using -syslibroot with ld, defining the SDK environment variables,
> directly specifying the right libSystem, etc. The furthest I've gotten
> was to resolve all symbols except for dyld_stub_binding_helper. I even
> tried a "hello world" program, with the same results.
>
> Has anyone got this to work?
>
> Alternatively... since these are Unix apps, could I just build them
> under OpenDarwin, and expect them to work under Mac OS X for Intel?
I haven't tried doing it from the command line. But from looking at
XCode 2.1's build log for a universal binary, the following looks to be
necessary:
1. Set this env var (I don't know if it's necessary, but XCode does it):
setenv MACOSX_DEPLOYMENT_TARGET 10.4
2. Use this gcc arg to specify universal:
-isysroot /Developer/SDKs/MacOSX10.4u.sdk
For what it's worth, the scheme XCode uses is to compile and link the
binary twice, once with -arch ppc and once with -arch i386. The
universal binary is then built from the two binaries using
/usr/bin/lipo. I don't know if specifying -arch twice would get the
desired result.
Depending on what you're doing, this might or might not be the right
approach. Universal binaries are only needed if you want to have one
precompiled binary that works on both architectures. If this was an
open-source project of some kind where the user could be expected to be
compiling their own copy, a better approach would probably be to have
the "configure" script recognize the architecture and proceed as
appropriate.
--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0: Delocalize, Repair Permissions, lots more.
See
http://www.atomicbird.com/