-
Notifications
You must be signed in to change notification settings - Fork 36
ffmpeg4.0.2编译
蔡兴明 edited this page Apr 27, 2020
·
1 revision
ffmpeg+centos编译环境搭建
1. open jdk
yum install java-1.8.0-openjdk* -y
2. 真正的jdk
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
- 发布日期2018-1-28
yum groupinstall Development tools
yum install gcc gcc-c++ gcc-g gcc-gnat gcc-java gcc-objc libgcj libgcj-devel libgnat libobjc libstdc++ zlib-devel zlib openssl openssl-devel
yum install cmake
sudo dnf group install "Development Tools"
通过检查工具二进制位置验证安装:
$ whereis bison gcc flex
bison: /usr/bin/bison /usr/share/bison /usr/share/man/man1/bison.1.gz /usr/share/info/bison.info.gz
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz /usr/share/info/gcc.info.gz
flex: /usr/bin/flex /usr/share/man/man1/flex.1.gz /usr/share/info/flex.info-1.gz /usr/share/info/flex.info-2.gz /usr/share/info/flex.info.gz
检查已经安装的GCC版本:
$ gcc --version
#!/bin/bash
NDK_ROOT=/root/ndk/android-ndk-r17c
#toolchain 变量指向ndk中的交叉编译gcc所在的目录
TOOLCHAIN=$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
#FLAGS与INCLUDES变量 可以从AS ndk工程的.externativeBuild/cmake/debug/armeabi-v7a/build.ninja中拷贝
FLAGS="-isystem $NDK_ROOT/sysroot/usr/include/arm-linux-androideabi -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -O0 -fPIC"
INCLUDES="-isystem $NDK_ROOT/sources/cxx-stl/llvm-libc++/include -isystem $NDK_ROOT/sources/android/support/include -isystem $NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include"
# 执行configure脚本,用于生成makefile
#--prefix :安装目录
#--enable-small:优化大小
#--isable-programs:不编译ffmpeg可执行程序,我们需要获得静态(动态)库
#--disable-avdevice:关闭avdevice模块,此模块在android中无用
#--disable-encoderrs:关闭所有的编码器,只需要播放decoder即可。
#--disable-muxers:没有推流无需muxer模块(复用器,封装器),不需要生成mp4这种文件,所以关闭
#--disable-filters:关闭视频滤镜
#--enable-cross-compile:开启交叉编译(ffmpeg比较**跨平台**,并不是所有库都有这么happy的选项)
#--cross-prefix:ndk的特定gcc编译器前缀
#--disable-shared enable-static: 不写也可以,默认就是这样的
#--sysroot
#--extra-cflags
#--arch --target-os
#
#
PREFIX=./android/armeabi-v7a
./configure \
--prefix=$PREFIX \
--enable-small \
--disable-programs \
--disable-avdevice \
--disable-encoders \
--disable-muxers \
--disable-filters \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--disable-shared \
--enable-static \
--sysroot=$NDK_ROOT/platforms/android-21/arch-arm \
--extra-cflags="$FLAGS $INCLUDES" \
--extra-cflags="-isysroot $NDK_ROOT/sysroot" \
--arch=arm \
--target-os=android
make clean
make
make install
- 错误一disable-muxers拼错
- `android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed.
2.1 查ffbuild/config.log
发现参数写错了-ffunction-sections
-f和function-sections分开了
3. -O0
写成了 -00
- glic错误 ,不影响最后生成共享库,这是ndk-r17c的bug在r18b和人6b中都没有,clang的问题.
/root/ndk/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /root/ndk/android-ndk-r17c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../bin/../lib/bfd-plugins/../lib64/libc++.so.1)
#!/bin/bash
NDK_ROOT=/root/ndk/android-ndk-r17c
#toolchain 变量指向ndk中的交叉编译gcc所在的目录
TOOLCHAIN=$NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
#FLAGS与INCLUDES变量 可以从AS ndk工程的.externativeBuild/cmake/debug/armeabi-v7a/build.ninja中拷贝
FLAGS="-isystem $NDK_ROOT/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv8-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -O0 -fPIC"
INCLUDES="-isystem $NDK_ROOT/sources/cxx-stl/llvm-libc++/include -isystem $NDK_ROOT/sources/android/support/include -isystem $NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include"
# 执行configure脚本,用于生成makefile
#--prefix :安装目录
#--enable-small:优化大小
#--isable-programs:不编译ffmpeg可执行程序,我们需要获得静态(动态)库
#--disable-avdevice:关闭avdevice模块,此模块在android中无用
#--disable-encoderrs:关闭所有的编码器,只需要播放decoder即可。
#--disable-muxers:没有推流无需muxer模块(复用器,封装器),不需要生成mp4这种文件,所以关闭
#--disable-filters:关闭视频滤镜
#--enable-cross-compile:开启交叉编译(ffmpeg比较**跨平台**,并不是所有库都有这么happy的选项)
#--cross-prefix:ndk的特定gcc编译器前缀
#--disable-shared enable-static: 不写也可以,默认就是这样的
#--sysroot
#--extra-cflags
#--arch --target-os
#
#
PREFIX=./android/arm64-v8a
./configure \
--prefix=$PREFIX \
--enable-small \
--disable-programs \
--disable-avdevice \
--disable-encoders \
--disable-muxers \
--disable-filters \
--enable-cross-compile \
--cross-prefix=$TOOLCHAIN/bin/aarch64-linux-androideabi- \
--enable-shared \
--disable-static \hjjjkkj
--sysroot=$NDK_ROOT/platforms/android-21/arch-arm64 \
--extra-cflags="$FLAGS $INCLUDES" \
--extra-cflags="-isysroot $NDK_ROOT/sysroot" \
--arch=aarch64 \
--target-os=android
make clean
make
make install