【问题标题】:ffmpeg won't ./configure in iOS5.1ffmpeg 在 iOS5.1 中不会 ./configure
【发布时间】:2012-04-16 11:21:41
【问题描述】:

当我尝试像这样运行 ./configure 时,我正在尝试在 iOS5.1 (armv7) 上构建 ffmpeg:

./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver
   --enable-cross-compile --arch=arm --target-os=darwin
   --cc=/applications/xcode.app/contents/Developer/usr/bin/gcc
   --as='gas-preprocessor/gas-preprocessor.pl /applications/xcode.app/contents/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

我收到以下错误:

/applications/xcode.app/contents/Developer/usr/bin/gcc
is unable to create an executable file.
C compiler test failed.

如果您认为配置出错,请确保您使用的是最新的 来自 SVN 的版本。如果最新版本失败,请将问题报告给 ffmpeg-user@mplayerhq.hu 邮件列表或 irc.freenode.net 上的 IRC #ffmpeg。 包括由 configure 生成的日志文件“config.err”,因为这将有所帮助 解决问题。

谁能提供iOS5.1的正确参数?

提前致谢

【问题讨论】:

    标签: iphone c ios ffmpeg


    【解决方案1】:

    说明已更改,因为 xcode SDK 中不再有 gcc

    您需要做的是指定 cc 是使用 xcrun 的 iphoneos 编译器,因此我们之前只是将路径放置到 gcc,现在我们将引用 xcrunclang

    我从 git 下载了最新的 ffmpeg,确保路径上有一个 gas-preprocess.pl 的副本,然后将 --cc= 行更改为:

    --cc='xcrun -sdk iphoneos clang -mios-version-min=5.1'
    

    (假设您正在构建并且仍然以 ios 5.1 为目标 - 如果您的目标是更新版本,那么您将值更改为更新版本。我为我指定了 7.0,但我也在使用 iOS 8.4 SDK,所以配置行看起来像:

    ./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver \
     --enable-cross-compile --arch=arm --target-os=darwin \
     --cc='xcrun -sdk iphoneos clang -mios-version-min=7.0' \
     --sysroot=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk \
     --cpu=cortex-a8 --extra-cflags='-arch armv7' \
     --extra-ldflags='-arch armv7 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk' \
     --enable-pic
    

    从 ios8.4 SDK 构建 ffmpeg。这些说明应继续有效;您只需为较新的 SDK 替换适当的 7.0/8.4 值。

    老答案

    当您尝试使用 MacOS 版本的编译器编译 iOS 代码时会发生这种情况。

    您需要使用以下命令指定 iPhoneOS 版本的 gcc:

    ./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/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
    

    尝试调试configure 问题的第一步是查看在运行过程中生成的config.log 文件。

    【讨论】:

    • 运行修改后的命令后,我在 config.log 中得到了这个:llvm-gcc-4.2: Invalid arch name : armv7 --extra-ldflags=-arch C 编译器测试失败。
    • 由于最新的 Xcode 版本(例如 6.4)在给定位置没有 gcc(/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ gcc) 我们该怎么办?
    • 考虑到这些说明是针对 iOS5 的,我并不奇怪事情发生了变化。我会更新说明。
    【解决方案2】:

    我可以看出您的配置脚本有一些问题。首先,您正在使用:

    --cc=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc 
    

    这是错误的。您应该使用特定于体系结构的 gcc 编译器,因此在您的情况下(armv7)您应该使用,例如:

    --cc=/applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1
    

    请注意,您调用的是苹果自己的 gcc 的 arm-apple-darwin10-gcc-4.2.1 版本。 由于这只是一个示例,请查看您的../Developer/../bin/ 并使用您拥有的最新arm-apple-darwin10-gcc-x.x.x。我看到有很多关于 SO 的答案建议您按照自己的方式进行操作,这完全是错误的!并且不适用于arm,仅适用于i386(模拟器)。

    您需要更新汇编器指令以反映使用相同的 gcc 版本:

    --as='gas-preprocessor/gas-preprocessor.pl /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1'
    

    另外,不要在您的--extra-cflags 中添加-arch armv7,您可能会得到一个 error: unrecognized command line option "-arch"

    最后,根据您的情况,除了您已有的之外,我是否可以提出以下建议:

    --disable-bzlib --disable-gpl --disable-shared --enable-static --disable-mmx --disable-debug --disable-neon
    

    改成这样:

    --extra-cflags='-pipe -Os -gdwarf-2 -isysroot /applications/xcode.app/contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -m${thumb_opt:-no-thumb} -mthumb-interwork'
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-28
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-28
      相关资源
      最近更新 更多