gpt4 book ai didi

android - 在 Mac 上编译 ffmpeg for android

转载 作者:太空狗 更新时间:2023-10-29 14:37:41 26 4
gpt4 key购买 nike

我试图在 Mac 上为 android 编译 ffmpeg,但它对我不起作用。

#!/bin/bash
NDK=/Users/user/Library/Android/sdk/ndk-bundle
SYSROOT=$NDK/platforms/android-18/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64

function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-network \
--disable-filters \
--disable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG

make clean all
make
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one

我还通过 chmod +x build_script.sh 授予执行权限

我尝试了 ffmpeg 4.14.0.3 但两者都不起作用并且错误原因相同。

我还尝试了 android-21android-18

test_cpp_condition stddef.h defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4
test_cpp
BEGIN /tmp/ffconf.bgSdFwkD/test.c
1 #include <stddef.h>
2 #if !(defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4)
3 #error "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4"
4 #endif
END /tmp/ffconf.bgSdFwkD/test.c
/Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -E -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c
/tmp/ffconf.bgSdFwkD/test.c:3:2: error: "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4"
#error "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4"
^
1 error generated.
test_cpp_condition stddef.h defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T
test_cpp
BEGIN /tmp/ffconf.bgSdFwkD/test.c
1 #include <stddef.h>
2 #if !(defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T)
3 #error "unsatisfied condition: defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T"
4 #endif
END /tmp/ffconf.bgSdFwkD/test.c
/Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -E -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c
test_ld cc
test_cc
BEGIN /tmp/ffconf.bgSdFwkD/test.c
1 int main(void){ return 0; }
END /tmp/ffconf.bgSdFwkD/test.c
/Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -march=armv4t -c -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c
/Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -march=armv4t -o /tmp/ffconf.bgSdFwkD/test /tmp/ffconf.bgSdFwkD/test.o
ld: unknown option: --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/
clang: error: linker command failed with exit code 1 (use -v to see invocation)
C compiler test failed.

是否需要额外安装任何工具/应用程序或库才能进行编译?我很困惑....(这个问题可能重复,但没有任何解决方案对我有用)

编辑 澄清我的系统环境。

  • Mac OS X High Sierra (10.13.6)
  • Android NDK (18.1.5063045)
  • Android SDK 工具和 SDK 构建工具
  • CMake

编辑 我也试过 ffmpeg 版本 3.3.9 但它也不起作用。

最佳答案

我是通过 Android Studio 安装 NDK 的,我认为这是问题所在,所以我手动下载了 Android NDK,现在我可以配置并运行 makefile。

等等!还没完成。当我用最新稳定的 NDK (r16b) 运行 makefile 时,它​​说:
./libavutil/common.h:33:19: fatal error :errno.h: 没有那个文件或目录

根据 this document ,所以我尝试使用 NDK r15c,它终于对我有用了。

总结一下我是如何解决这个问题的:手动安装 NDK r15c 并且不要忘记更新你的 shell 脚本文件!

希望对您有所帮助!!

关于android - 在 Mac 上编译 ffmpeg for android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53385391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com