Compiling a universal binary with GCC
15 inch Powerbook G4, Mac OS X (10.5.2)
Apple Event: May 7th at 7 am PT
15 inch Powerbook G4, Mac OS X (10.5.2)
# Makefile
# Create universal executable
hello: hello.i386 hello.ppc
lipo -create -output hello hello.ppc hello.i386
# Create Intel executable
hello.i386: hello.c
gcc -arch i386 -o hello.i386 hello.c
# Create PPC executable
hello.ppc: hello.c
gcc -arch ppc -o hello.ppc hello.c
/* hello.c */
#include <stdio.h>
int main(void)
{
printf("Hello world ");
return 0;
}
$ file hello
hello: Mach-O universal binary with 2 architectures
hello (for architecture ppc7400): Mach-O executable ppc
hello (for architecture i386): Mach-O executable i386
$ /usr/libexec/oah/translate hello
Hello world
-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -mmacosx-version-min=10.4
-isysroot /Developer/SDKs/MacOSX10.3.9.sdk -arch ppc -mmacosx-version-min=10.3
lipo -create <myapp>.ppc <myapp>.i386 -output <myapp>
Compiling a universal binary with GCC