从http://site.icu-project.org/ 下载icu,解压到icu目录。
在当前目录创建空目录hostbuild,进入hostbuild目录,运行sh ../icu/source/runConfigureICU MacOSX.
mkdir hostbuild
cd hostbuild
sh ../icu/source/runConfigureICU MacOSX
gnumake
然后设置PATH,CFLAGS,CPPFLAGS等环境变量。
DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
SDKROOT=$DEVROOT/SDKs/iPhoneOS4.3.sdk
SYSROOT=$SDKROOT
ICU_MYSRC=/Users/.../icu
export CXXPP=
export CXXPPFLAGS=
export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$SDKROOT/usr/llvm-gcc-4.2/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$SDKROOT/usr/include/ -I$SDKROOT/usr/include/c++/4.2.1/armv7-apple-darwin10/ -I./include/ -I$ICU_MYSRC/source/common/ -I$ICU_MYSRC/source/tools/tzcode/ -miphoneos-version-min=2.2"
export CFLAGS="$CPPFLAGS -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="$DEVROOT/usr/bin/cpp $CPPFLAGS"
export CXXFLAGS="$CFLAGS"
export CC="$DEVROOT/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-gcc-4.2"
export CXX="$DEVROOT/usr/llvm-gcc-4.2/bin/arm-apple-darwin10-llvm-g++-4.2"
export LDFLAGS="-L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip -miphoneos-version-min=2.0"
sh ../icu/source/configure --host=arm-apple-darwin --enable-static --disable-shared -with-cross-build=.../hostbuild
-with-cross-build要使用绝对路径,用的时候替换一下。
创建cross compile目录iphonebuild。
mkdir iphonebuild
cd iphonebuild
sh ../icu/source/configure --host=arm-apple-darwin --enable-static --disable-shared -with-cross-build=.../hostbuild
gmake