编译FFmpeg跟着网上的介绍始终走不通,一直报错:
CC libavfilter/aeval.o
In file included from libavfilter/aeval.c:26:0:
./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^
compilation terminated.
make: *** [libavfilter/aeval.o] Error 1
CC libavfilter/aeval.o
In file included from libavfilter/aeval.c:26:0:
./libavutil/avassert.h:30:20: fatal error: stdlib.h: No such file or directory
#include <stdlib.h>
^
compilation terminated.
make: *** [libavfilter/aeval.o] Error 1
后来发现是因为新版本的NDK引起的,因为NDK江头文件和库文件进行了分离,指定的sysroot只有库文件,头文件放在NDK目录下的sysroot内,只需在--extra-cflags中添加 "-isysroot NDK/sysroot" 即可,还有有关汇编的头文件也进行了分离,需要根据目标平台进行指定 "-INDK/sysroot/usr/include/arm-linux-androideabi",将 "arm-linux-androideabi" 改为需要的平台就可以,终于可以顺利的进行编译了。
最终使用到的脚本:
#!/bin/bash
NDK=/Users/admin/Library/Android/sdk/ndk-bundle
API=19
PLATFORM=arm-linux-androideabi
TOOLCHAIN=$NDK/toolchains/$PLATFORM-4.9/prebuilt/darwin-x86_64
SYSROOT=$NDK/platforms/android-$API/arch-arm/
ISYSROOT=$NDK/sysroot
ASM=$ISYSROOT/usr/include/$PLATFORM
CPU=arm
PREFIX=$(pwd)/android/$CPU
build_one()
{
./configure \
--prefix=$PREFIX \
--target-os=android \
--arch=arm \
--cpu=$CPU \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--disable-asm \
--enable-cross-compile \
--enable-shared \
--disable-static \
--enable-runtime-cpudetect \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-symver \
--enable-small \
--enable-gpl --enable-nonfree --enable-version3 --disable-iconv \
--enable-jni \
--enable-mediacodec \
--disable-decoders --enable-decoder=vp9 --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=aac \
--disable-encoders --enable-encoder=vp9_vaapi --enable-encoder=h264_nvenc --enable-encoder=h264_v4l2m2m --enable-encoder=hevc_nvenc \
--disable-demuxers --enable-demuxer=rtsp --enable-demuxer=rtp --enable-demuxer=flv --enable-demuxer=h264 \
--disable-muxers --enable-muxer=rtsp --enable-muxer=rtp --enable-muxer=flv --enable-muxer=h264 \
--disable-parsers --enable-parser=mpeg4video --enable-parser=aac --enable-parser=h264 --enable-parser=vp9 \
--disable-protocols --enable-protocol=rtmp --enable-protocol=rtp --enable-protocol=tcp --enable-protocol=udp \
--disable-bsfs \
--disable-indevs --enable-indev=v4l2 \
--disable-outdevs \
--disable-filters \
--disable-postproc \
--sysroot=$SYSROOT \
--extra-cflags="-I$ASM -isysroot $ISYSROOT -D__ANDROID_API__=$API -U_FILE_OFFSET_BITS -Os -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -marm" \
--extra-ldflags="-marm"
$ADDITIONAL_CONFIGURE_FLAG
}
build_one
make clean
make -j4
make install
使用的替换NDK路径。
参考的链接:
https://blog.csdn.net/leixiaohua1020/article/details/47008825
https://blog.csdn.net/luo0xue/article/details/80048847
网友评论