preface

In order to ensure that the audio format is versatile and you need to convert the audio to MP3 format, this article shows you how to compile the LAME library using Shell scripts.

Compile the script

#! /bin/sh CONFIGURE_FLAGS="--disable-shared --disable-frontend" ARCHS="arm64 armv7s armv7 x86_64 i386" MIN_VERSION="10.0" # directories SOURCE="lame" FAT="fat-lame" SCRATCH="scratch-lame" # must be an absolute path 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` 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 else PLATFORM="iPhoneOS" SIMULATOR= HOST=arm-apple-darwin fi XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` CC="xcrun -sdk $XCRUN_SDK clang -arch $ARCH -miphoneos-version-min=${MIN_VERSION}" #AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC" CFLAGS="-arch $ARCH $SIMULATOR" if ! xcodebuild -version | grep "Xcode [1-6]\." then CFLAGS="$CFLAGS -fembed-bitcode" fi 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 fiCopy the code

Using the step

  1. Download the lame
  2. After decompressionlamePut it in the same folder as the script
  3. Modify thelameFolder name, excluding version number
  4. Open terminal and switch to folder path
  5. performshellThe script

Matters needing attention

  1. Do not include Chinese in the folder path
  2. fatVersion includes real machine and emulator