Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile Android dynamic Library

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to compile Android dynamic Library", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to compile Android dynamic Library" article.

C++ 2.FFmpeg-4.3.2 compiles Android dynamic library (ubuntu 18.04r21b) compilation environment

Linux system:

Ubuntu18.04

NDK

Ndk/android-ndk-r21b

FFmpeg

Ffmpeg-4.3.2

File name after ffmpeg download

Ffmpeg_4.3.2.orig.tar.xz

Decompression mode

Tar xvJf ffmpeg_4.3.2.orig.tar.xz

Operate under root permission

Compiling version 4.3.2 does not need to modify the configure file to write an Android compilation script

Create a new file build_android.sh

#! / bin/bash# ndk path NDK=/home/build/workspace/hqq/vision/vision-app/ndk/android-ndk-r21b# compilation tool chain directory. Clang is used in ndk17 version above. The following is the root directory of the gccTOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64# version number API=21# cross-compilation tree (looking for the corresponding header files and libraries) SYSROOT= "${TOOLCHAIN} / sysroot" # defines the shell method function build_android () {. / configure\-prefix=$PREFIX\-enable-shared\-- disable-static\-- enable-jni\ that executes configure -- enable-gpl\-- enable-small\-- disable-doc\-- disable-programs\-- disable-symver\-- target-os=android\-- arch=$ARCH\-- cpu=$CPU\-- cc=$CC\-- cxx=$CXX\-enable-cross-compile\-- cross-prefix=$CROSS_COMPILE\-- sysroot=$SYSROOT \-- extra-cflags= "- Os-fpic $OPTIMIZE_CFLAGS"\-- extra-ldflags= "\-- disable-asm\ $COMMON_FF_CFG_FLAGS make clean make-j16 make install} # armOUTPUT_FOLDER=armARCH=armCPU=armv7-aTOOL_CPU_NAME=armv7aTOOL_PREFIX=$TOOLCHAIN/bin/$ {TOOL_CPU_NAME}-linux-androideabiOPTIMIZE_CFLAGS="-marm-march=$CPU "PREFIX=$ {PWD} / android/$OUTPUT_FOLDERCROSS_COMPILE=$TOOLCHAIN/bin/arm-linux- Androideabi-CC=$ {TOOL_PREFIX} ${API}-clangCXX=$ {TOOL_PREFIX} ${API}-clang++build_android# arm64 This instruction set supports a minimum of api21OUTPUT_FOLDER=arm64-v8aARCH=aarch64CPU=armv8-aTOOL_CPU_NAME=aarch64TOOL_PREFIX=$TOOLCHAIN/bin/$ {TOOL_CPU_NAME}-linux-androidOPTIMIZE_CFLAGS= "- march=$CPU" PREFIX=$ {PWD} / android/$OUTPUT_FOLDERCROSS_COMPILE=$TOOLCHAIN/bin/aarch64-linux-android-CC=$ {TOOL_PREFIX} ${API}-clangCXX=$ {TOOL_PREFIX} ${API}-clang++build_android# x86OTUTPUTOEFOLDERY x86ARCHY-86CPU-min x86TOOLY CPUBING i686TOOLPREFIXPREFIXY TOOLCHAING binder ${TOOL_CPU_NAME}-linux-androidOPTIMIZE_CFLAGS= "- march=i686- Mtune=intel-mssse3-mfpmath=sse-M32 "PREFIX=$ {PWD} / android/$OUTPUT_FOLDERCROSS_COMPILE=$TOOLCHAIN/bin/i686-linux-android-CC=$ {TOOL_PREFIX} ${API}-clangCXX=$ {TOOL_PREFIX} ${API}-clang++build_android# x86room64 This instruction set supports a minimum of api21OUTPUT_FOLDER=x86_64ARCH=x86_64CPU=x86-64 tooling CPUBING named names x86-64 TOOLING PREFIXPREFIXINTOOLCHAING ${TOOL_CPU_NAME}-linux-androidOPTIMIZE_CFLAGS= "- march=$CPU-mtune=intel-msse4.2-mpopcnt-M64" # output directory PREFIX=$ {PWD} / android/$OUTPUT_FOLDERCROSS_COMPILE=$TOOLCHAIN/bin/x86_64-linux-android-# so output directory,-- libdir=$LIB_DIR may not be specified # LIB_DIR= "${PWD} / android/libs/$OUTPUT_FOLDER" # compiler CC=$ {TOOL_PREFIX} ${API}-clangCXX=$ {TOOL_PREFIX} ${API}-clang++build_android is generated by default in the $PREFIX/lib directory

Modify file permissions

Chmod 777 build_android.sh

Execute build_android.sh

Can compile "armeabi-v7a", "arm64-v8a", "x86", "x86" 64

If the compilation fails, when you open the file to paste

: set ff # if you look at the file format, you will see fileformat=dos or fileformat=unix

: set ff=unix # set to unix format

: wq # Save exit

Compiled file

Take the .so library and put it in the Android project

Github lib library

Android_ffmpeg_lib

Taxiao213/android_ffmpeg_lib

The above is about the content of this article on "how to compile Android dynamic Library". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report