转自:http://blog.csdn.net/cjj198561/article/details/38382889
编译准备
1.代码下载
在mac下面执行:wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
也可以用网页打开下载,不过我用网页打开下载老是失败,后来就命令下载一次性成功。
2.代码编译
下载以后解压文件,解压以后的文件名修改为faac
3.写脚本文件
编写build-faac.sh文件,内容如下:
- #!/bin/sh
- CONFIGURE_FLAGS="--enable-static --with-pic"
- ARCHS="arm64 armv7s armv7 x86_64 i386"
- # directories
- SOURCE="faac"
- FAT="fat-faac"
- SCRATCH="scratch-faac"
- # must be an absolute path
- THIN=`pwd`/"thin-faac"
- 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`
- 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"
- CPU=
- if [ "$ARCH" = "x86_64" ]
- then
- SIMULATOR="-mios-simulator-version-min=7.0"
- HOST=
- else
- SIMULATOR="-mios-simulator-version-min=5.0"
- HOST="--host=i386-apple-darwin"
- fi
- else
- PLATFORM="iPhoneOS"
- if [ $ARCH = "armv7s" ]
- then
- CPU="--cpu=swift"
- else
- CPU=
- fi
- SIMULATOR=
- HOST="--host=arm-apple-darwin"
- fi
- XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
- CC="xcrun -sdk $XCRUN_SDK clang -Wno-error=unused-command-line-argument-hard-error-in-future"
- AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC"
- CFLAGS="-arch $ARCH $SIMULATOR"
- CXXFLAGS="$CFLAGS"
- LDFLAGS="$CFLAGS"
- CC=$CC CFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS CPPFLAGS=$CXXFLAGS CXX=$CC CXXFLAGS=$CXXFLAGS $CWD/$SOURCE/configure \
- $CONFIGURE_FLAGS \
- $HOST \
- --prefix="$THIN/$ARCH" \
- --disable-shared \
- --without-mp4v2
- make clean && make && make install-strip
- 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
4.编译
为编写的文件增加执行权限
chmod +x build-faac.sh
然后执行脚本
./build-faac.sh
完成以后会生成如下目录,对应的库和头文件在fat-faac文件夹里面
fat-faac是thin-faac里面的各个平台合并以后的库和头文件