【问题标题】:problem compiling ffmpeg for iFrameExtractor为 iFrameExtractor 编译 ffmpeg 的问题
【发布时间】:2011-10-23 01:49:38
【问题描述】:

我正在尝试使用iFrameExtractor example 中的make 和build 文件来编译ffmpeg。首先,我尝试遵循 github 上的自述文件,它只说在 ffmpeg 文件夹中运行 ./build_universal。它没有工作

然后我尝试按照 INSTALL 中的信息进行操作,但没有成功。然后我尝试在 INSTALL 中做这些事情,然后是 ./build_universal,但没有成功。导入到项目中的所有 *.a 文件都存在,直到构建序列结束。当 build_universal 中的 lipo 命令运行时,我猜想连接不同架构的 .a 文件(?)。无论如何,这些都会留下以下错误:

lipo: specifed architecture type (armv6) for file (armv6/libavcodec.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavdevice.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavformat.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libavutil.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))
lipo: specifed architecture type (armv6) for file (armv6/libswscale.a) does not match it's cputype (16777223) and cpusubtype (3) (should be cputype (12) and cpusubtype (6))

如果我只使用./build_armv7,我可以让项目为模拟器编译,但如果我运行通用,.a 文件最终会被删除。并且仅使用无法为 iphone 4 构建。

【问题讨论】:

    标签: iphone ios ffmpeg armv6


    【解决方案1】:

    经过一周的反复试验,我终于能够创建 ffmpeg 通用库,并成功为设备和模拟器编译和运行 iFrameExtractor。

    在您的 iPhone 设备或模拟器上编译和运行项目:

    1) 打开终端

    2) 克隆仓库:git clone git://github.com/lajos/iFrameExtractor.git

    3)进入项目中的ffmpeg文件夹:cd iFrameExtractor/ffmpeg

    4) 运行:./configure

    5) 编辑构建脚本(build_armv6、build_armv7、build_i386)如下:

    这些脚本假定您在 Xcode 4.2 上使用 iOS SDK 5.0。

    build_armv6:

    #!/bin/tcsh -f
    
    if (! -d armv6) mkdir armv6
    if (! -d lib) mkdir lib
    
    rm armv6/*.a
    
    make clean
    
    ./configure \
    --disable-bzlib --disable-doc \
    --disable-ffmpeg --disable-ffplay \
    --disable-ffserver --disable-mmx \
    --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
    --enable-cross-compile --target-os=darwin \
    --arch=arm --cpu=arm1176jzf-s \
    --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
    --extra-ldflags="-arch armv6 -L//Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
    --extra-cflags="-arch armv6"
    
    make
    
    mv libavcodec/libavcodec.a armv6/
    mv libavdevice/libavdevice.a armv6/
    mv libavformat/libavformat.a armv6/
    mv libavutil/libavutil.a armv6/
    mv libswscale/libswscale.a armv6/
    
    rm lib/*.a
    
    cp armv6/*.a lib/
    

    build_armv7:

    #!/bin/tcsh -f
    
    if (! -d armv7) mkdir armv7
    if (! -d lib) mkdir lib
    
    rm armv7/*.a
    
    make clean
    
    ./configure \
    --disable-bzlib --disable-doc \
    --disable-ffmpeg --disable-ffplay \
    --disable-ffserver --disable-mmx \
    --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
    --enable-cross-compile --target-os=darwin \
    --arch=arm --cpu=cortex-a8 --enable-pic \
    --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk \
    --extra-ldflags="-arch armv7 -    L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/system" \
    --extra-cflags="-arch armv7"
    
    make
    
    mv libavcodec/libavcodec.a armv7/
    mv libavdevice/libavdevice.a armv7/
    mv libavformat/libavformat.a armv7/
    mv libavutil/libavutil.a armv7/
    mv libswscale/libswscale.a armv7/
    
    rm lib/*.a
    
    cp armv7/*.a lib/
    

    build_i386:

    #!/bin/tcsh -f
    
    if (! -d i386) mkdir i386
    if (! -d lib) mkdir lib
    
    rm i386/*.a
    
    make clean
    
    ./configure \
    --disable-bzlib --disable-doc \
    --disable-ffmpeg --disable-ffplay \
    --disable-ffserver --disable-mmx \
    --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    --as='gas-preprocessor/gas-preprocessor.pl     /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
    --sysroot=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk \
    --extra-ldflags="-arch i386 -L//Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/lib/system" \
    --extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
    
    make
    
    mv libavcodec/libavcodec.a i386/
    mv libavdevice/libavdevice.a i386/
    mv libavformat/libavformat.a i386/
    mv libavutil/libavutil.a i386/
    mv libswscale/libswscale.a i386/
    
    rm lib/*.a
    
    cp i386/*.a lib/
    

    6) 构建 ffmpeg 库:./build_universal

    7) 打开 xcode 项目并在您的 iPhone 设备或模拟器上运行它

    这些步骤非常适合我。我希望这将有助于其他努力使 ffmpeg 库适用于 iOS 的人。

    【讨论】:

    • 你能联系我吗,在这种情况下我需要一些外包编程(oleksiivinogradov Skype)或 oleksiivinogradov@me.com 电子邮件
    • 嗨@Far Pointer,我按照您的所有步骤进行操作,但没有成功编译 iFrameExtractor。我使用的是 Xcode 4.2。您能帮我解决这个问题吗?
    【解决方案2】:

    我下载了最新的 ffmpeg 存储库并使用以下内容仅针对 armv6 和 armv7 进行编译。我无法让它为 i386 工作,我收到 cputype 和 subcputype 错误的错误。显然 cputype 应该是 x86 而 subcputype 应该是 intel。

    无论如何,我使用以下构建脚本来编译 arm 架构:

    构建脚本:

    #!/bin/sh
    
    set -e
    
    SCRIPT_DIR=$( (cd -P $(dirname $0) && pwd) )
    DIST_DIR_BASE=${DIST_DIR_BASE:="$SCRIPT_DIR/dist"}
    
    if [ -d ffmpeg ]
    then
      echo "Found ffmpeg source directory, no need to fetch from git..."
    else
      echo "Fetching ffmpeg from git://git.videolan.org/ffmpeg.git..."
      git clone git://git.videolan.org/ffmpeg.git
    fi
    
    ARCHS=${ARCHS:-"armv6 armv7"}
    
    for ARCH in $ARCHS
    do
        FFMPEG_DIR=ffmpeg-$ARCH
        if [ -d $FFMPEG_DIR ]
        then
          echo "Removing old directory $FFMPEG_DIR"
          rm -rf $FFMPEG_DIR
        fi
        echo "Copying source for $ARCH to directory $FFMPEG_DIR"
        cp -a ffmpeg $FFMPEG_DIR
    
        cd $FFMPEG_DIR
    
        DIST_DIR=$DIST_DIR_BASE-$ARCH
        mkdir -p $DIST_DIR
    
        case $ARCH in
            armv6)
                EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s"
                EXTRA_CFLAGS="-arch $ARCH"
                EXTRA_LDFLAGS="-arch $ARCH"
                ;;
            armv7)
                EXTRA_FLAGS="--enable-cross-compile --target-os=darwin --arch=arm --cpu=cortex-a8 --enable-pic"
                EXTRA_CFLAGS="-arch $ARCH"
                EXTRA_LDFLAGS="-arch $ARCH"
                ;;
            x86_64)
                EXTRA_CC_FLAGS="-mdynamic-no-pic"
                ;;
        esac
    
        echo "Configuring ffmpeg for $ARCH..."
        ./configure \
        --prefix=$DIST_DIR \
        --extra-ldflags=-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/system \
        --disable-bzlib \
        --disable-doc \
        --disable-ffmpeg \
        --disable-ffplay \
        --disable-ffserver \
        --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
        --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk \
        --extra-ldflags="$EXTRA_LDFLAGS" \
        --extra-cflags="$EXTRA_CFLAGS" \
        $EXTRA_FLAGS
    
        echo "Installing ffmpeg for $ARCH..."
        make && make install
    
        cd $SCRIPT_DIR
    
        if [ -d $DIST_DIR/bin ]
        then
          rm -rf $DIST_DIR/bin
        fi
        if [ -d $DIST_DIR/share ]
        then
          rm -rf $DIST_DIR/share
        fi
    done
    

    并结合 libs 脚本:

    #!/bin/bash
    
    set -e
    
    ARCHS="armv6 armv7"
    
    for ARCH in $ARCHS
    do
      if [ -d dist-$ARCH ]
      then
        MAIN_ARCH=$ARCH
      fi
    done
    
    if [ -z "$MAIN_ARCH" ]
    then
      echo "Please compile an architecture"
      exit 1
    fi
    
    
    OUTPUT_DIR="dist-uarch"
    rm -rf $OUTPUT_DIR
    
    mkdir -p $OUTPUT_DIR/lib $OUTPUT_DIR/include
    
    for LIB in dist-$MAIN_ARCH/lib/*.a
    do
      LIB=`basename $LIB`
      LIPO_CREATE=""
      for ARCH in $ARCHS
      do
        if [ -d dist-$ARCH ]
        then
          LIPO_CREATE="$LIPO_CREATE-arch $ARCH dist-$ARCH/lib/$LIB "
        fi
      done
      OUTPUT="$OUTPUT_DIR/lib/$LIB"
      echo "Creating: $OUTPUT"
      lipo -create $LIPO_CREATE -output $OUTPUT
      lipo -info $OUTPUT
    done
    
    echo "Copying headers from dist-$MAIN_ARCH..."
    cp -R dist-$MAIN_ARCH/include/* $OUTPUT_DIR/include
    

    然后我从 BUILD-FOLDER/dist-uarch 导入 .a 文件,它像魅力一样在 xcode 中构建!

    【讨论】:

    • 构建良好,但现在有链接错误:(有 39 个,这里是一个示例)架构 armv7 的未定义符号:“_ff_vector_fmul_vfp”,引用自:libavcodec.a 中的_ff_dsputil_init_vfp(dsputil_init_vfp.o)“ _main",引用自:从crt1.3.1.o开始"_av_solve_lls",引用自:libavcodec.a(lpc.o)中的_ff_lpc_calc_coefs"_ff_float_to_int16_vfp",引用自:libavcodec.a(dsputil_init_vfp.o)中的_ff_dsputil_init_vfp(dsputil_init_vfp.o) ld:符号(s) 未找到架构 armv7
    • 感觉我也有这个,不太确定。进口情况如何?可能是您必须为导入添加另一个搜索路径。单击目标 -> 构建设置选项卡 -> 搜索路径 -> 并更改标题/库搜索路径以匹配构建文件的位置!
    • 这对我也有用。干得好!我采取的其他步骤是更改脚本中的 sdk 版本。我还需要在标志中添加“--disable-asm”。最后,我需要更新我的标题搜索路径。
    【解决方案3】:

    为 iOS 5.1 构建 FFMPEG

    希望这将帮助您为 iOS 5.1 构建最新的 FFMPEG

    git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
    
    cd ffmpeg
    
    ./build_universal
    

    注意:您必须先创建 build_* 脚本,要执行此操作,请参阅下面的代码

    ARMV7 脚本 - 创建文件 build_armv7

    #!/bin/tcsh -f
    
    if (! -d armv7) mkdir armv7
    if (! -d lib) mkdir lib
    
    rm armv7/*.a
    
    make clean
    
    ./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7' --extra-ldflags='-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk' --enable-pic
    
    make
    
    mv libavcodec/libavcodec.a armv7/
    mv libavdevice/libavdevice.a armv7/
    mv libavformat/libavformat.a armv7/
    mv libavutil/libavutil.a armv7/
    mv libswscale/libswscale.a armv7/
    
    rm lib/*.a
    
    cp armv7/*.a lib/
    

    ARMV6 脚本 - 创建文件 build_armv6

    #!/bin/tcsh -f
    
    if (! -d armv6) mkdir armv6
    if (! -d lib) mkdir lib
    
    rm armv6/*.a
    
    make clean
    
    ./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable-cross-compile --arch=arm --target-os=darwin --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk --cpu=arm1176jzf-s --extra-cflags='-arch armv6' --extra-ldflags='-arch armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk'
    
    make
    
    mv libavcodec/libavcodec.a armv6/
    mv libavdevice/libavdevice.a armv6/
    mv libavformat/libavformat.a armv6/
    mv libavutil/libavutil.a armv6/
    mv libswscale/libswscale.a armv6/
    
    rm lib/*.a
    
    cp armv6/*.a lib/
    

    模拟器脚本 - 创建文件 build_i386

    #!/bin/tcsh -f
    
    if (! -d i386) mkdir i386
    if (! -d lib) mkdir lib
    
    rm i386/*.a
    
    make clean
    
    ./configure \
    --disable-bzlib --disable-doc \
    --disable-ffmpeg --disable-ffplay \
    --disable-ffserver --disable-mmx \
    --cc=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc \
    --as='gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' \
    --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk \
    --extra-ldflags="-arch i386 -L//Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/lib/system" \
    --extra-cflags="-arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -fasm-blocks -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2"
    
    make
    
    mv libavcodec/libavcodec.a i386/
    mv libavdevice/libavdevice.a i386/
    mv libavformat/libavformat.a i386/
    mv libavutil/libavutil.a i386/
    mv libswscale/libswscale.a i386/
    
    rm lib/*.a
    
    cp i386/*.a lib/
    

    通用构建脚本(将库合并为一个通用)- 创建文件 build_universal

    #!/bin/tcsh -f
    
    source ./build_armv6
    source ./build_armv7
    source ./build_i386
    
    if (! -d universal) mkdir universal
    if (! -d lib) mkdir lib
    
    rm universal/*.a
    
    lipo -create -arch armv6 armv6/libavcodec.a -arch armv7 armv7/libavcodec.a -arch i386 i386/libavcodec.a -output universal/libavcodec.a
    lipo -create -arch armv6 armv6/libavdevice.a -arch armv7 armv7/libavdevice.a -arch i386 i386/libavdevice.a -output universal/libavdevice.a
    lipo -create -arch armv6 armv6/libavformat.a -arch armv7 armv7/libavformat.a -arch i386 i386/libavformat.a -output universal/libavformat.a
    lipo -create -arch armv6 armv6/libavutil.a -arch armv7 armv7/libavutil.a -arch i386 i386/libavutil.a -output universal/libavutil.a
    lipo -create -arch armv6 armv6/libswscale.a -arch armv7 armv7/libswscale.a -arch i386 i386/libswscale.a -output universal/libswscale.a
    
    rm lib/*.a
    
    cp universal/*.a lib/
    

    【讨论】:

      猜你喜欢
      • 2012-09-06
      • 1970-01-01
      • 1970-01-01
      • 2013-08-13
      • 2019-07-05
      • 2016-07-08
      • 1970-01-01
      相关资源
      最近更新 更多