FFMPEG source compilation failed with Android NDK

2019-07-25 14:45发布

问题:

while compiling FFMPEG source with Android NDK Clang compiler (r16b), I'm getting compiler error.

for the below config:

./configure \
--prefix=/home/prasaathviki/Desktop/ffmpeg/bin/android/26/arm64_26 \
--cross- 
prefix=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android- \
--sysroot="/home/prasaathviki/Desktop/depends/android/ndk/mytoolchains/r16b/arm64_26/sysroot" \
--disable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-symver \
--enable-shared \
--enable-protocol=concat \
--enable-protocol=file \
--enable-muxer=mp4 \
--enable-demuxer=mpegts \
--target-os=android \
--enable-decoder=h264 \
--enable-cross-compile \
--arch=arm \
--cpu=arm \
--toolchain=clang-usan \
--extra-cflags="-fPIE -fPIC -ffast-math -funroll-loops -mfloat-abi=softfp -mfpu=vfpv3-d16" \
--extra-ldflags="-pie" \
--cc=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang \
--cxx=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang++ \
--ld=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-ld \
--as=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang \
--ar=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-ar \
--strip=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-strip

In ffbuild/Config.log i'm getting this below error..

/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang --sysroot=/home/prasaathviki/Desktop/depends/android/ndk/mytoolchains/r16b/arm64_26/sysroot -fsanitize=undefined -fPIE -fPIC -ffast-math -funroll-loops -mfloat-abi=softfp -mfpu=vfpv3-d16 -mcpu=arm -c -o /tmp/ffconf.Hn6wyaNC/test.o /tmp/ffconf.Hn6wyaNC/test.c
clang50: error: the clang compiler does not support '-mcpu=arm'
C compiler test failed.

Also i have tried without --cpu flag, but still it reported an error as below

/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang --sysroot=/home/prasaathviki/Desktop/depends/android/ndk/mytoolchains/r16b/arm64_26/sysroot -fsanitize=undefined -fPIE -fPIC -ffast-math -funroll-loops -mfloat-abi=softfp -mfpu=vfpv3-d16 -mcpu= -c -o /tmp/ffconf.gQNwoHgC/test.o /tmp/ffconf.gQNwoHgC/test.c
clang50: warning: joined argument expects additional value: '-mcpu=' [-Wunused-command-line-argument]
clang50: error: the clang compiler does not support '-mcpu='
C compiler test failed.

Please help me to resolve this issue. Thanks.

回答1:

--arch=arm \
--cpu=arm \
...
--cc=/home/prasaathviki/Desktop/ndk/mytoolchains/r16b/arm64_26/bin/aarch64-linux-android-clang \
...

You're giving configure an arm64 toolchain and telling it to build arm32. Use the arm-linux-androideabi toolchain for building arm32 and aarch64-linux-android for building arm64.