Use NDK (r20) compile FFmpeg

Two days ago saw a question at the forum, the effect is how to use NDK-r20 compiled FFmpeg under UBUNTU. My first reaction is not supposed to r20, because I was used earlier versions of NDK no gcc, I found many problems can not be compiled, immediately responded to a use r12b to compile. I got home fine thought for a moment, if I just want the latest FFmpeg compiled by NDK r20 it? Why do not we take a moment to toss down.

NDK do not know what a thorough reform of the version used to compile clang, this is not the most critical in the new NDK in sysroot also changed (the key is to build a google sysroot- wrong sysroot in the root directory NDK), This leads to over-cc FFmpeg can not detect. Crtbegin_so.o common error is not connected or can not find the library system.

So sysroot is actually the culprit, if we use the right sysroot everything easier to handle. I used a tricky way to view sysroot, build a c ++ project in AS, the piece of code intentionally wrong grade of the log can see inside clearly marked sysroot ($ NDK / toolchains / llvm / prebuilt use / linux -x86_64 / sysroot) that is what we need.

Learn to look at log

Many students encounter compilation problem will only capture terminal, in fact, true log in ffbuild / conf.log, there is a detailed description of what is wrong.

The correct configuration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
the NDK = Export / Home / fgodt / the Android / Sdk / NDK the bundle- 
Export = 22 is the API
Export the ARCH = aarch64
Export the PLATFORM = aarch64
Export the TARGET = $ Android the PLATFORM-Linux-
Export TOOLCHAIN = $ the NDK / toolchains / LLVM / the prebuilt / Linux- x86_64 / bin
# correct sysroot
Export sYSROOT = $ NDK / toolchains / LLVM / prebuilt / Linux-x86_64 / sysroot
Export the CPU = aarch64
Export PREFIX = / Home / fgodt / FFmpeg / Android / $ the CPU
Export CFLAG = "-D__ANDROID_API __ = $ -Os -fPIC -DANDROID API "\
######################################### #############
# aarch64 not need --cpu, if other cpu add the following sentence
# - cpu = $ PLATFORM \
############ ##########################################
./configure \
--prefix=$PREFIX \
--cc=$TOOLCHAIN/$TARGET$API-clang \
--cxx=$TOOLCHAIN/$TARGET$API-clang++ \
--ld=$TOOLCHAIN/$TARGET$API-clang \
--target-os=android \
--arch=$ARCH \
--cross-prefix=$TOOLCHAIN/$ARCH-linux-android- \
--disable-asm \
--enable-cross-compile \
--disable-shared \
--disable-doc \
--enable-runtime-cpudetect \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-decoders \
--disable-encoders \
--disable-devices \
--sysroot=$SYSROOT \
--extra-cflags="$CFLAG" \
--extra-ldflags=""

note

Configuring here simply to verify whether the compile, you should cut FFmpeg according to their needs, if you need hardware acceleration and other functions also need to add the JNI configuration and open MediaCodec.

As sysroot at the root of what use I have not studied fine, white for no reason we can not rely on one more sysroot it.

Finally, I hope useful for students not yet compiled

Guess you like

Origin www.cnblogs.com/fgodt/p/ffmpegforndk.html