|
From: | Perrog |
Subject: | can libtool do universal binary |
Date: | Fri, 11 May 2007 11:45:44 +0200 |
Hi!
Has anyone been using libtool for universal binary builds on Mach-O/Mac OS X? Are there any other platform that have similar requirements? In summary, an "universal build" is a Mach-O object or binary file format containing both PowerPC and Intel architectures, in an architecture independend file format. Basically, you run gcc two times and build it for ppc, then for i386. Lastly you use a magic tool, in this case "lipo", that combines the two architectures into a single binary file.
Are there other platforms having parallells to universal builds? What would this really require from libtool? Or should universal builds be handled by other methods?
===== Example, showing the basic commands used. Build each architecture in own folders, then combine them into a single binary.
# Directory layout:
$ ll
drwxr-xr-x 6 perrog perrog 204 May 11 11:26 ./
drwx------ 17 perrog perrog 578 May 11 10:50 ../
-rw-r--r-- 1 perrog perrog 73 May 11 10:53 foo.c
drwxr-xr-x 6 perrog perrog 204 May 11 11:21 i386/
drwxr-xr-x 6 perrog perrog 204 May 11 11:20 ppc/
drwxr-xr-x 3 perrog perrog 102 May 11 11:26 universal/
(
cd ppc # build Power PC architecture
libtool --mode=compile gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -g -O -c ../foo.c
libtool --mode=link gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -g -O -o libfoo.la foo.lo -version-info 1:1:0 -rpath /usr/local/lib
)
(
cd i386 # Build Intel architecture
libtool --mode=compile gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -g -O -c ../foo.c
libtool --mode=link gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -g -O -o libfoo.la foo.lo -version-info 1:1:0 -rpath /usr/local/lib
)
# Inspecting architectures with file command
$ file i386/.libs/libfoo.1.0.1.dylib ppc/.libs/libfoo.1.0.1.dylib
i386/.libs/libfoo.1.0.1.dylib: Mach-O dynamically linked shared library i386
ppc/.libs/libfoo.1.0.1.dylib: Mach-O dynamically linked shared library ppc
(
cd universal # Combine PowerPC and Intel architectures
lipo -create ../i386/.libs/libfoo.1.0.1.dylib ../ppc/.libs/libfoo.1.0.1.dylib -output libfoo.1.0.1.dylib
)
# Inspecting architecture with file command
$ file universal/libfoo.1.0.1.dylib
universal/libfoo.1.0.1.dylib: Mach-O universal binary with 2 architectures
universal/libfoo.1.0.1.dylib (for architecture i386): Mach-O dynamically linked shared library i386
universal/libfoo.1.0.1.dylib (for architecture ppc): Mach-O dynamically linked shared library ppc
[Prev in Thread] | Current Thread | [Next in Thread] |