问题描述:这里在编译arm64-v8a时候遇到问题:boringssl在编译webrtc被依赖,ffmpeg依赖openssl这样会冲突。
0、先上节网上参考地址。热热身。
https://blog.csdn.net/sonysuqin/article/details/79679134
https://www.jianshu.com/p/221a27881c41
https://www.jianshu.com/p/ee9d7bdd9447
1、解决办法:二选一,因为他们接口都一样。没有办法。
用两套如果完全对上版本还好, 但是这个可能性不大。
1.1、都用boringssl编译。
这里重点说下,boringssl编译arm64-v8a问题,直接上贴脚本吧
#!/bin/sh
export ANDROID_NDK=/Users/zhangyf/Library/Android/sdk/ndk/android-ndk-r17c
export ANDROID_HOME=/Users/zhangyf/Library/Android/sdk
$ANDROID_HOME/cmake/3.10.2.4988404/bin/cmake \
-DANDROID_ABI=arm64-v8a \
-DCMAKE_MAKE_PROGRAM=$ANDROID_HOME/cmake/3.10.2.4988404/bin/ninja \
-DANDROID_NATIVE_API_LEVEL=21 \
-DANDROID_NDK=$ANDROID_NDK \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-GNinja \
../src
cmake --build .
ffmpeg编译,也是直接上脚本吧。
#!/bin/bash
LIBRARY_TARGET_ABI="$1"
VERSION="3.3.1" # ffmpeg使用的版本号
NDK_ROOT=/home/shenpengliang/Android/android-ndk-r14b
ANDROID_API=android-21
CURRENT=$PWD
ADDI_CFLAGS=""
ADDI_LDFLAGS=""
SSL_INCLUDE=""
SSL_LIB=""
FDK_INCLUDE=""
FDK_LIB=""
LAME_INCLUDE=""
LAME_LIB=""
if [ -d "${CURRENT}/ffmpeg-${VERSION}" ]; then
#rm -rf "${CURRENT}/ffmpeg-${VERSION}"
echo "has source file"
else
echo "extracting tar file now..."
tar jxf ffmpeg-${VERSION}.tar.bz2 -C "${CURRENT}"
echo "extracting done"
fi
if [ "$LIBRARY_TARGET_ABI" == "armeabi-v7a" ]
then
CONFIGURE_AARCH=arm
SYSROOT=${NDK_ROOT}/platforms/${ANDROID_API}/arch-arm
PREBUILT=${NDK_ROOT}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
CROSS_PREFIX=${PREBUILT}/bin/arm-linux-androideabi-
ARM_INCLUDE=${NDK_ROOT}/sysroot/usr/include
ARM_LIB=${NDK_ROOT}/platforms/${ANDROID_API}/arch-arm/usr/lib
SYSTEM=${NDK_ROOT}/sysroot/usr/include/arm-linux-androideabi
CFLAGS="-mfloat-abi=softfp -marm -march=armv7-a"
SSL_INCLUDE=$CURRENT/thirdparty/armv7a/openssl/include/
SSL_LIB=$CURRENT/thirdparty/armv7a/openssl/lib/
FDK_INCLUDE=$CURRENT/thirdparty/armv7a/fdk/include/
FDK_LIB=$CURRENT/thirdparty/armv7a/fdk/lib/
LAME_INCLUDE=$CURRENT/thirdparty/armv7a/lame/include/
LAME_LIB=$CURRENT/thirdparty/armv7a/lame/lib/
elif [ "$LIBRARY_TARGET_ABI" == "arm64-v8a" ]
then
CONFIGURE_AARCH=aarch64
SYSROOT=${NDK_ROOT}/platforms/${ANDROID_API}/arch-arm64
PREBUILT=${NDK_ROOT}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
CROSS_PREFIX=${PREBUILT}/bin/aarch64-linux-android-
ARM_INCLUDE=${NDK_ROOT}/sysroot/usr/include
ARM_LIB=${NDK_ROOT}/platforms/${ANDROID_API}/arch-arm64/usr/lib
SYSTEM=${NDK_ROOT}/sysroot/usr/include/aarch64-linux-android
CFLAGS="-march=armv8-a"
SSL_INCLUDE=$CURRENT/thirdparty/armv8a/openssl/include/
SSL_LIB=$CURRENT/thirdparty/armv8a/openssl/lib/
FDK_INCLUDE=$CURRENT/thirdparty/armv8a/fdk/include/
FDK_LIB=$CURRENT/thirdparty/armv8a/fdk/lib/
LAME_INCLUDE=$CURRENT/thirdparty/armv8a/lame/include/
LAME_LIB=$CURRENT/thirdparty/armv8a/lame/lib/
elif [ "$LIBRARY_TARGET_ABI" == "x86" ]
then
CONFIGURE_AARCH=x86
SYSROOT=${NDK_ROOT}/platforms/${ANDROID_API}/arch-x86
PREBUILT=${NDK_ROOT}/toolchains/x86-4.9/prebuilt/linux-x86_64
CROSS_PREFIX=${PREBUILT}/bin/i686-linux-android-
ARM_INCLUDE=${NDK_ROOT}/sysroot/usr/include
ARM_LIB=${NDK_ROOT}/platforms/${ANDROID_API}/arch-x86/usr/lib
SYSTEM=${NDK_ROOT}/sysroot/usr/include/i686-linux-android
CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
elif [ "$LIBRARY_TARGET_ABI" == "x86_64" ]
then
CONFIGURE_AARCH=x86_64
SYSROOT=${NDK_ROOT}/platforms/${ANDROID_API}/arch-x86_64
PREBUILT=${NDK_ROOT}/toolchains/x86_64-4.9/prebuilt/linux-x86_64
CROSS_PREFIX=${PREBUILT}/bin/x86_64-linux-android-
ARM_LIB=${NDK_ROOT}/platforms/${ANDROID_API}/arch-x86_64/usr/lib64
SYSTEM=${NDK_ROOT}/sysroot/usr/include/x86_64-linux-android
CFLAGS="-march=x86-64 -mtune=intel -m64 -funroll-loops -ffast-math"
else
echo "Unsupported target ABI: $LIBRARY_TARGET_ABI"
exit 1
fi
ADDI_CFLAGS="-I${SSL_INCLUDE} -I${FDK_INCLUDE} -I${LAME_INCLUDE}"
ADDI_LDFLAGS="-L${SSL_LIB} -L${FDK_LIB} -L${LAME_LIB}"
PREFIX=${CURRENT}/out/${LIBRARY_TARGET_ABI}
#export PKG_CONFIG_PATH="$(pwd)/pkg_config"
ARM_INCLUDE=${NDK_ROOT}/sysroot/usr/include
function build_one
{
./configure \
--prefix=${PREFIX} \
--arch=${CONFIGURE_AARCH} \
--target-os=android \
--enable-cross-compile \
--cross-prefix=${CROSS_PREFIX} \
--sysroot=${SYSROOT} \
--enable-static \
--disable-shared \
--disable-doc \
--disable-programs \
--disable-asm \
--disable-debug \
--enable-pthreads \
--disable-symver \
--enable-small \
--disable-muxers \
--disable-encoders \
--disable-parsers \
--disable-filters \
--disable-hwaccels \
--disable-bsfs \
--disable-decoders \
--disable-protocols \
--disable-demuxers \
--enable-runtime-cpudetect \
--enable-hardcoded-tables \
--enable-jni \
--enable-mediacodec \
--enable-decoder=h264_mediacodec \
--enable-hwaccel=h264_mediacodec \
--enable-protocol=concat,file,rtmp,rtmps \
--enable-protocol=http \
--enable-protocol=tcp \
--enable-protocol=udp \
--enable-demuxer=flv \
--enable-demuxer=hls \
--enable-demuxer=mpegts \
--enable-demuxer=mov \
--enable-decoder=h264 \
--enable-decoder=aac \
--enable-decoder=aasc \
--enable-decoder=mp3 \
--enable-nonfree \
--enable-decoder=aac_latm \
--enable-parser=aac \
--enable-parser=h264 \
--enable-nonfree \
--enable-protocol=https \
--enable-openssl \
--enable-protocol=crypto \
--enable-protocol=tls_openssl \
--enable-libfdk_aac \
--enable-encoder=libfdk_aac \
--enable-libmp3lame \
--enable-encoder=libmp3lame \
--extra-cflags="$ADDI_CFLAGS -DANDROID -O3 -fPIC -fasm -isystem ${SYSTEM} ${CFLAGS}" \
--extra-ldflags="$ADDI_LDFLAGS -lz -lc -lm -ldl -llog" \
--cxx=${CROSS_PREFIX}g++ \
--extra-libs="-lgcc"
make clean all
make
make install
}
cd "${CURRENT}/ffmpeg-${VERSION}"
build_one
1.2 另外一种选择:都用openssl 网上有人着么做, owt貌似也是这么做的。
这个我没有试,因为还有别的工程curl也用到boringssl 。