Mac OS X10.10_xcode6.1_ios8.1環境下,編譯lame靜態庫libmp3lame.a,支持arm64 armv7s x86_64 i386 armv7指令集
近期升級了系統到Mac OS X 10.10 而且更新了XCode6.1和iOS 8.1
之前app用到的libmp3lame.a靜態庫。也要支持64位的模擬器(x86_64)和64位的真機(arm64)指令集。須要又一次編譯
查閱了下資料,依照例如以下步驟,並做了些凝視和修改
1.http://sourceforge.net/projects/lame/files/lame/3.99/ 下載lame的最新版本號解壓到一個文件夾裏比如 lame,全路徑例如以下/Users/8wm/Desktop/lame
2.下載build的腳本。我這裏使用的是國外一個朋友的分享
https://github.com/kewlbear/lame-ios-build
下載之後得到lame-build.sh復制到文件夾/Users/8wm/Desktop/lame
3.用bbedit或者其它編輯器打開這個腳本,依照凝視修改
4.打開Terminals。
輸入
cd
/Users/8wm/Desktop/lame
chmod 777 lame-build.sh
sudo -s#
輸入系統password
./lame-build.sh
開始編譯。編譯完畢之後。生成fat-lame文件夾和thin-lame文件夾。分別存放合並全部指令集的靜態庫,以及各指令集的靜態庫.
依據所需。copy lame.h和
能夠使用命令行,查看換個庫支持的指令集。
lipo -info libmp3lame.a
Architectures
in the fat file: libmp3lame.a are: armv7 armv7s i386 x86_64 arm64
下面是build的腳本,請註意黃色的字和凝視。
#!/bin/sh make distclean CONFIGURE_FLAGS="--disable-shared --disable-frontend" ARCHS="arm64 armv7s x86_64 i386 armv7" # directories # SOURCE是下載lame源代碼包,解壓後的文件夾,能夠把sh腳本放到這個文件夾,source改為"" SOURCE="" # FAT是全部指令集build後,輸出的文件夾。全部靜態庫被合並成一個靜態庫 FAT="fat-lame" # SCRATCH是下載lame源代碼包,解壓後的文件夾,必須是絕對路徑 SCRATCH="/Users/8wm/Desktop/lame" # must be an absolute path # THIN 各自指令集build後輸出的靜態庫所在的文件夾,每一個指令集為一個靜態庫 THIN=`pwd`/"thin-lame" COMPILE="y" LIPO="y" if [ "$*" ] then if [ "$*" = "lipo" ] then # skip compile COMPILE= else ARCHS="$*" if [ $# -eq 1 ] then # skip lipo LIPO= fi fi fi if [ "$COMPILE" ] then CWD=`pwd` echo "$CWD/$SOURCE........." for ARCH in $ARCHS do echo "building $ARCH..." mkdir -p "$SCRATCH/$ARCH" cd "$SCRATCH/$ARCH" if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ] then PLATFORM="iPhoneSimulator" if [ "$ARCH" = "x86_64" ] then SIMULATOR="-mios-simulator-version-min=7.0" HOST=x86_64-apple-darwin else SIMULATOR="-mios-simulator-version-min=5.0" HOST=i386-apple-darwin fi else PLATFORM="iPhoneOS" SIMULATOR= HOST=arm-apple-darwin fi XCRUN_SDK=`echo $PLATFORM | tr ‘[:upper:]‘ ‘[:lower:]‘` CC="xcrun -sdk $XCRUN_SDK clang -arch $ARCH" #AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC" CFLAGS="-arch $ARCH $SIMULATOR" CXXFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" CC=$CC $CWD/$SOURCE/configure $CONFIGURE_FLAGS --host=$HOST --prefix="$THIN/$ARCH" CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" make -j3 install cd $CWD done fi if [ "$LIPO" ] then echo "building fat binaries..." mkdir -p $FAT/lib set - $ARCHS CWD=`pwd` cd $THIN/$1/lib for LIB in *.a do cd $CWD lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB done cd $CWD cp -rf $THIN/$1/include $FAT fi
Mac OS X10.10_xcode6.1_ios8.1環境下,編譯lame靜態庫libmp3lame.a,支持arm64 armv7s x86_64 i386 armv7指令集