使用Xcode5.1错误编译iOS版的FFmpeg



环境:Mac OS X 10.9.2,Xcode 5.1。构建如下shell脚本:

#!/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".

--额外的cflags=-arch i386-mfpu=neon-miphoneos版本min=4.3

这里似乎有两件事不对。

首先,config.log显示--extra-cflags=<args>没有正确转义。因此,FFmpeg/配置脚本看到--extra-cflags=-archi386-mfpu=neoni386本身不是脚本的有效标志,因此它失败了。

您可以将您的脚本与我在github上维护的脚本进行比较。我想知道如果在脚本中使用变量展开,而不是变量替换,会发生什么?例如

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

尝试:

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

其次,-mfpu=neon-arch i386放在一起没有意义。看起来这个脚本正在通过包含PLATFORM="iPhoneOS"而不是PLATFORM="iPhoneSimulator"的big-if语句的分支。这是行不通的。

所以,我不是100%确定修复,但这些都是你的一些问题。

相关内容

  • 没有找到相关文章

最新更新