ios - 使用 Xcode5.1 为 iOS 编译 FFmpeg 错误

标签 ios xcode macos ffmpeg cross-compiling

环境: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". ?

最佳答案

--extra-cflags=-arch i386 -mfpu=neon -miphoneos-version-min=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" 的大 if 语句的分支。 , 而不是 PLATFORM="iPhoneSimulator" .那是行不通的。

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

关于ios - 使用 Xcode5.1 为 iOS 编译 FFmpeg 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23151796/

相关文章:

ios - iOS 中具有多个 TableView 的屏幕的容器 View ?

ios - 如何在不使用单独的包的情况下将我的资源文件包含在我的框架中?

ios - 通过深层链接打开 View Controller 时导航栏消失

xcode - 代码签名 : Identifier of Designated Requirements mismatches app identifier

ios - AV Foundation 相机预览图层被放大,如何缩小?

ios - 在 Swift 3 中从本地文件加载数据对象

ios - 为什么 CSS background-size : cover not work in portrait mode on iOS?

swift - UITableView 滚动到底部时加载更多

objective-c - 在沙盒应用程序中获取用户在 Mac 上的下载文件夹的 API

windows - VBA - Windows 和 OSX 中的用户名