2014-04-18 116 views
0

環境:Mac OS X 10.9.2,Xcode 5.1。建立shell腳本如下:使用Xcode5.1編譯FFmpeg for iOS錯誤

#!/bin/sh 

# OS X 10.9.2, Xcode 5.1 

set -ex 

VERSION="2.2.1" 
SDKVERSION="7.1" 
BUILDDIR=`pwd` 
DESTDIR="ffmpeg-built" 
OUTPUTDIR="dependencies" 
DEVELOPER=`xcode-select -print-path` 
GASPREPROCESSOR="gas-preprocessor.pl" 
ARCHS="i386 x86_64 armv7 armv7s arm64" 

cp $GASPREPROCESSOR /usr/local/bin 

rm -rf $DESTDIR 
mkdir $DESTDIR 

rm -rf $OUTPUTDIR 
mkdir $OUTPUTDIR 
mkdir -p $OUTPUTDIR/bin 
mkdir -p $OUTPUTDIR/include 
mkdir -p $OUTPUTDIR/lib 

if [ ! -e "ffmpeg-$VERSION.tar.bz2" ]; then 
    curl -LO http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2 
fi 

tar jxf ffmpeg-$VERSION.tar.bz2 
cd "ffmpeg-$VERSION" 

set +e 
CCACHE=`which ccache` 
if [ $? == "0" ]; then 
    CCACHE="$CCACHE " 
else 
    CCACHE="" 
fi 
set -e 

for ARCH in $ARCHS; 
do 
    mkdir -p ../$DESTDIR/$ARCH 

    make distclean 

    IOSMV="-miphoneos-version-min=4.3" 
    if [ $ARCH == "arm64" ]; then 
     IOSMV="-miphoneos-version-min=7.0" 
    fi 
    CONFIG="--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile" 

    if [ "$ARCH" == "i386" ]; 
    then 
     PLATFORM="iPhoneSimulator" 
     EXTRA_CONFIG="--arch=i386 --target-os=darwin --cpu=i386 --disable-asm --enable-pic" 
     EXTRA_CFLAGS="-arch i386" 
     EXTRA_LDFLAGS="-I$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk/usr/lib -mfpu=neon" 
    else 
     PLATFORM="iPhoneOS" 
     EXTRA_CONFIG="--arch=arm --target-os=darwin --cpu=cortex-a8 --disable-armv5te --enable-pic" 
     EXTRA_CFLAGS="-w -arch $ARCH -mfpu=neon" 
     EXTRA_LDFLAGS="-mfpu=neon" 
    fi 

    ./configure --prefix=$BUILDDIR/$DESTDIR/$ARCH --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-iconv --disable-bzlib --enable-avresample --sysroot="$DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk" --cc="$DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" --as='/usr/local/bin/$GASPREPROCESSOR' --extra-cflags="$EXTRA_CFLAGS -miphoneos-version-min=$SDKVERSION -I$BUILDDIR/$OUTPUTDIR/include" --extra-ldflags="-arch $ARCH $EXTRA_LDFLAGS -isysroot $DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk -miphoneos-version-min=$SDKVERSION -L$BUILDDIR/$OUTPUTDIR/lib" $EXTRA_CONFIG --enable-pic --extra-cxxflags="$CPPFLAGS -I$BUILDDIR/$OUTPUTDIR/include -isysroot $DEVELOPER/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDKVERSION.sdk" 

    make 
    make install 
done 
make distclean 

cd .. 
mkdir -p $DESTDIR/universal/lib 
cd $DESTDIR/i386/lib 

for FILE in *.a; 
do 
    INPUT="" 
    for ARCH in $ARCHS; 
    do 
     INPUT="$INPUT $DESTDIR/$ARCH/lib/$FILE" 
    done 
    lipo -create $INPUT -output $DESTDIR/universal/lib/$FILE 
done 

但終端登錄的是:

+ VERSION=2.2.1 
+ SDKVERSION=7.1 
++ pwd 
+ BUILDDIR=/Users/Smeegol/Desktop/FFmpeg 
+ DESTDIR=ffmpeg-built 
++ xcode-select -print-path 
+ DEVELOPER=/Applications/Xcode.app/Contents/Developer 
+ ARCHS='i386 x86_64 armv7 armv7s arm64' 
+ rm -rf ffmpeg-built 
+ mkdir ffmpeg-built 
+ '[' '!' -e ffmpeg-2.2.1.tar.bz2 ']' 
+ tar jxf ffmpeg-2.2.1.tar.bz2 
+ cd ffmpeg-2.2.1 
+ set +e 
++ which ccache 
+ CCACHE= 
+ '[' 1 == 0 ']' 
+ CCACHE= 
+ set -e 
+ for ARCH in '$ARCHS' 
+ mkdir -p ../ffmpeg-built/i386 
+ IOSMV=-miphoneos-version-min=4.3 
+ '[' i386 == arm64 ']' 
+ CONFIG='--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile' 
+ '[' i386 == i386 ']' 
+ PLATFORM=iPhoneSimulator 
+ EXTRA_CONFIG='--arch=i386 --target-os=darwin --cpu=i386 --enable-pic --disable-asm' 
+ EXTRA_CFLAGS='-arch i386 -mfpu=neon -miphoneos-version-min=4.3' 
+ ./configure --prefix=/Users/Smeegol/Desktop/FFmpeg/ffmpeg-built/i386 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avresample --enable-cross-compile --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --extra-cflags=-arch i386 -mfpu=neon -miphoneos-version-min=4.3 '--extra-ldflags=-arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -miphoneos-version-min=4.3' --arch=i386 --target-os=darwin --cpu=i386 --enable-pic --disable-asm 
Unknown option "i386". 
See ./configure --help for available options. 

爲什麼Unknown option "i386".

回答

0

--extra-CFLAGS = -arch i386的-mfpu =霓虹燈-miphoneos版本分鐘= 4.3

兩件事情似乎錯在這裏。

首先,config.log顯示--extra-cflags=<args>未正確轉義。因此,FFmpeg的./configure腳本看到--extra-cflags=-arch,i386,-mfpu=neon;單獨的i386不是腳本的有效標誌,因此它失敗。

您可以將腳本與the one I maintain on github進行比較。我想知道如果你在腳本中使用變量擴展,而不是變量替換,會發生什麼?例如

--extra-cflags="$EXTRA_CFLAGS -miphoneos-versi....

...嘗試:

--extra-cflags="${EXTRA_CFLAGS} -miphoneos-versi....

其次,-mfpu=neon-arch i386在一起,沒有任何意義。它看起來像這個腳本正在通過包含PLATFORM="iPhoneOS"而不是PLATFORM="iPhoneSimulator"的big if語句的分支。這是行不通的。

所以,我不是100%肯定的修復,但這些都是你的一些問題。