2014-04-18 1 views
0

환경 : Mac OS X 10.9.2, Xcode 5.1. 다음과 같이 쉘 스크립트를 작성 :Xcode5.1 오류를 사용하여 iOS 용 FFmpeg 컴파일

#!/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"이 포함 된 big if 문의 분기를 통과하며 PLATFORM="iPhoneSimulator"이 아닌 것으로 보입니다. 그것은 단지 작동하지 않을 것입니다.

그래서 수정본을 100 % 확신하지는 않지만 그 중 일부는 사용자의 문제입니다.