Universal Binary Error while linking during cross-compilation

Hi all,
I have 2 or so questions about building Universal binaries.

  1. I’m trying to cross compile from an i386 MacBook Pro to support
    PowerPC I am getting the following error when linking to SDL…

“warning /sw/lib//libSDLMain.a archive’s cputype(7, architecture i386)
does not match (18) for specified -arch flag:ppc(can’t load from it)”

Any ideas?

  1. How do i386 and PowerPC binaries co-exist in the same application
    bundle? Do they sit in separate directories? How does the OS know which
    binary to run?

Thanks,

Dominique.

How
do
i386
and
PowerPC
binaries
co-exist
in
the
same
application bundle?
Do
they
sit
in
separate

directories?
How
does
the
OS
know
which binary
to
run?

I’m not certain how it works in this case, but I know that under the old 68K architecture, the program code was stored in CODE resources in the resource fork, whereas under PowerPC, the program code was stored in the data fork. This made it very easy to create a “fat binary” program that would run under both environments; just include both builds, each in its own default location, and let the system look for the code where it normally looks for it. I imagine there’s something similar going on in i386/PowerPC binaries.

Hello !

  1. How do i386 and PowerPC binaries co-exist in the same application
    bundle? Do they sit in separate directories? How does the OS know which
    binary to run?

From what i know the same as the normal binarys, they sit in FAT exes,
FAT librarys, …

As Mac OS X knows on what processor it is currently running,
it then simply picks the PPC part, the X86 part or whatever.

With lipo you can check these FAT files, lipo -info

CU

Hi all,
I have 2 or so questions about building Universal binaries.

  1. I’m trying to cross compile from an i386 MacBook Pro to support
    PowerPC I am getting the following error when linking to SDL…

“warning /sw/lib//libSDLMain.a archive’s cputype(7, architecture i386)
does not match (18) for specified -arch flag:ppc(can’t load from it)”

Any ideas?

/sw/lib, is that Fink? I don’t think Fink installs Universal Binaries,
just native binaries. So you can’t cross-compile against it if this is
true.

  1. How do i386 and PowerPC binaries co-exist in the same application
    bundle? Do they sit in separate directories? How does the OS know which
    binary to run?

It is a single file containing all the different architectures. This
is called a “fat” binary. OS X inherits this feature from NeXTSTEP.
It’s been around, but has just been dormant for a long time.

Mach-O is the component that is responsible for picking/dealing with
the correct parts.

Look up “fat binary” on Wikipedia, and search the Xcode documentation
for “Universal Binary” for more information.

-EricOn 2/22/08, Dominique Louis wrote: