因为android只能加载*.so结尾的动态库,不能识别如*.so.57结尾的
#SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
#LIB_INSTALL_EXTRA_CMD='?(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
#SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
#SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)’
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='?(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'
在终端输入以下命令设置权限(具体目录根据自身情况修改):
chmod 777 /Users/**/ffmpeg-3.2.4/build_android.sh
进入ffmpeg目录下终端输入命令:
./configure
注意如果不输入这一步,后面编译时会报错
Unknown option "--disable-ffserver"...
上述操作完成后,编写android编译脚本
在ffmpeg-3.2.4/下创建 build_android.sh文件,并将以下内容复制到此文件:
#!/bin/bash
export NDK_HOME=/Users/*/Library/Android/sdk/ndk-bundle
export PLATFORM_VERSION=android-14
function build
echo "start build ffmpeg for $ARCH"
./configure --target-os=linux \
--prefix=$PREFIX --arch=$ARCH \
--disable-doc \
--enable-shared \
--disable-static \
--disable-yasm \
--disable-asm \
--disable-symver \
--enable-gpl \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--cross-prefix=$CROSS_COMPILE \
--enable-cross-compile \
--sysroot=$SYSROOT \
--enable-small \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make install
echo "build ffmpeg for $ARCH finished"
ARCH=arm
CPU=arm
PREFIX=/Users/*/Documents/ffmpeg-4.1.3/arm
TOOLCHAIN=$NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64
CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi-
ADDI_CFLAGS="-marm"
SYSROOT=$NDK_HOME/platforms/$PLATFORM_VERSION/arch-$ARCH/
build
ARCH=x86
CPU=x86
PREFIX=/Users/*/Documents/ffmpeg-4.1.3/arm/x86
TOOLCHAIN=$NDK_HOME/toolchains/x86-4.9/prebuilt/darwin-x86_64
CROSS_COMPILE=$TOOLCHAIN/bin/i686-linux-android-
ADDI_CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
SYSROOT=$NDK_HOME/platforms/$PLATFORM_VERSION/arch-$ARCH/
build
上述脚本需要根据自身实际安装的目录进行一些修改:
保存后执行:
./build_android.sh
等待一段时间后 需要的so文件就生成在对应目录啦
iamtofu
粉丝