This shows how to create universal static library to use c/c++ code for iPhone applications. Here, my cpp code is MathFuncsLib.cpp and MathFuncsLib.h.
I created following script file and run it to get "libMathFuncsLib-fat.a".
#!/bin/bash
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk -mmacosx-version-min=10.5 -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000 -arch i386 -c -o MathFuncsLib_i386.o MathFuncsLib.cpp
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk -miphoneos-version-min=3.0 -arch armv6 -c -o MathFuncsLib_armv6.o MathFuncsLib.cpp
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar rc MathFuncsLib_i386.a MathFuncsLib_i386.o
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar rc MathFuncsLib_armv6.a MathFuncsLib_armv6.o
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ranlib MathFuncsLib_i386.a
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib MathFuncsLib_armv6.a
lipo MathFuncsLib_i386.a MathFuncsLib_armv6.a -create -output libMathFuncsLib-fat.a