iOS lame編譯 arm64 armv7s armv7 x86_64 i386指令集,arm64armv7s

來源:互聯網
上載者:User

【轉】iOS lame編譯 arm64 armv7s armv7 x86_64 i386指令集,arm64armv7s

原文出至 http://blog.csdn.net/vieri_ch/article/details/40650467

最近升級了系統到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#

輸入系統密碼

./lame-build.sh

開始編譯,編譯完成之後。產生fat-lame目錄和thin-lame目錄,分別存放合并所有指令集的靜態庫,以及各指令集的靜態庫.

根據所需,copy lame.h和libmp3lame.a檔案到project裡,就可以正常使用了。

可以使用命令列,查看換個庫支援的指令集。

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

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.