3rd party libraries used by iPhone applications are required to be linked statically. In order to build such a library for the device and simulator you need to set up your environment such that it will cross compile for the two different environments. This is as simple as using the following set of ‘exports’ as defined below.
Device:
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk export CC=$DEVROOT/usr/bin/gcc export LD=$DEVROOT/usr/bin/ld export CPP=$DEVROOT/usr/bin/cpp export CXX=$DEVROOT/usr/bin/g++ export AR=$DEVROOT/usr/bin/ar export AS=$DEVROOT/usr/bin/as export NM=$DEVROOT/usr/bin/nm export CXXCPP=$DEVROOT/usr/bin/cpp export RANLIB=$DEVROOT/usr/bin/ranlib export LDFLAGS="-arch armv6 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -L~$SDKROOT/usr/lib" export CFLAGS="-arch armv6 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -I~$SDKROOT/usr/include" export CXXFLAGS="-arch armv6 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -I~$SDKROOT/usr/include0"
Simulator:
export DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator3.0.sdk export CC=$DEVROOT/usr/bin/gcc export LD=$DEVROOT/usr/bin/ld export CPP=$DEVROOT/usr/bin/cpp export CXX=$DEVROOT/usr/bin/g++ export AR=$DEVROOT/usr/bin/ar export AS=$DEVROOT/usr/bin/as export NM=$DEVROOT/usr/bin/nm export CXXCPP=$DEVROOT/usr/bin/cpp export RANLIB=$DEVROOT/usr/bin/ranlib export LDFLAGS="-arch i386 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -L~$SDKROOT/usr/lib" export CFLAGS="-arch i386 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -I~$SDKROOT/usr/include" export CXXFLAGS="-arch i386 -pipe -Os -gdwarf-2 -no-cpp-precomp -isysroot $SDKROOT -I~$SDKROOT/usr/include"
Once you have set the environment, you just need to use ‘make’ to build the library. If the library is using autoconf, then you will need to use the following ‘./configure’ options:
Device:
./configure --host=arm-apple-darwin9 --prefix=~$SDKROOT --enable-shared=no
Simulator:
./configure --host=i386-apple-darwin --prefix=~$SDKROOT --enable-shared=no
Then just use ‘make’ and ‘make install’ to build the library! It really is as easy as that
.
[Other libraries may require other configure options, but I can't cover them all here as they are often different]

Why the “~” before $SDKROOT? Also wondering why the -no-cpp-precomp. Don’t you usually also want to pass in the references to the SDK frameworks via “-F”? Also some headers are not in the simulator SDK (e.g. in_systm.h) I guess that needs another “-I”.
Currently fighting myself with this stuff
Hi Torsten,
The ~ is to put it into your home directory. Sometimes that works, sometimes you need to specify it directly with /Users/ etc.
The -no-cpp-precomp came from somewhere else to be honest. I’m a little vague on what it *actually* does, but it seems that for most libraries it’s required / works.
You don’t want to pass in references to the SDK frameworks usually. That would only be required if the library you are compiling for is specially coded for the iPhone and in which case you probably wouldn’t be reading this anyway because they would have created the Makefile specially for the iPhone.
Do you need any specific help with the package you are trying to compile?