Compiling FFmpeg 2.3 with Android NDK r10

Robin

I want to compile FFMpeg 2.3 with Android NDK r10 by following this tutorial: http://www.roman10.net/how-to-build-ffmpeg-for-android/

After getting several errors i modified the build script like this:

  #!/bin/bash
    ######################################################
# Usage:
# put this script in top of FFmpeg source tree
# ./build_android
# It generates binary for following architectures:
# ARMv6 
# ARMv6+VFP 
# ARMv7+VFPv3-d16 (Tegra2) 
# ARMv7+Neon (Cortex-A8)
# Customizing:
# 1. Feel free to change ./configure parameters for more features
# 2. To adapt other ARM variants
# set $CPU and $OPTIMIZE_CFLAGS 
# call build_one
######################################################
NDK=/usr/local/src/android-ndk-r10
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
function build_one
{
./configure --target-os=linux \
    --prefix=$PREFIX \
    --enable-cross-compile \
    --extra-libs="-lgcc" \
    --arch=arm \
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
    --sysroot=$PLATFORM \
    --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
    --disable-shared \
    --enable-static \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --disable-everything \
    --enable-demuxer=mov \
    --enable-demuxer=h264 \
    --disable-ffplay \
    --enable-protocol=file \
    --enable-avformat \
    --enable-avcodec \
    --enable-decoder=rawvideo \
    --enable-decoder=mjpeg \
    --enable-decoder=h263 \
    --enable-decoder=h265 \
    --enable-decoder=mpeg4 \
    --enable-decoder=h264 \
    --enable-parser=h264 \
    --enable-parser=h265
    --enabled-network \
    --enable-zlib \
    --disable-avfilter \
    --disable-avdevice \
    $ADDITIONAL_CONFIGURE_FLAG

make clean
make  -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -nostdlib,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.8/libgcc.a
}

#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU 
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one

#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU 
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one

#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp 
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

But unfortunatly I get the following error:

    INSTALL ffmpeg
INSTALL ffprobe
INSTALL ffserver
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(eventfd.o): multiple definition of 'eventfd'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(eventfd.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): multiple definition of '__dorand48'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): multiple definition of '__rand48_mult'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): multiple definition of '__rand48_add'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): multiple definition of '__rand48_seed'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(_rand48.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libm.a(s_scalbn.o): multiple definition of 'ldexp'
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: /usr/local/src/android-ndk-r10/platforms/android-8/arch-arm//usr/lib/libc.a(ldexp.o): previous definition here
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: cannot find -lz
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: cannot find -ldl
/usr/local/src/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: error: cannot find -llog
libavformat/http.c:384: error: undefined reference to 'inflateEnd'
libavformat/http.c:385: error: undefined reference to 'inflateInit2_'
libavformat/http.c:390: error: undefined reference to 'zlibCompileFlags'
libavformat/http.c:1029: error: undefined reference to 'inflateEnd'
libavformat/http.c:867: error: undefined reference to 'inflate'
libavformat/id3v2.c:840: error: undefined reference to 'uncompress'
libavformat/mov.c:2934: error: undefined reference to 'uncompress'
bionic/libc/bionic/drand48.c:24: error: undefined reference to '_rand48_seed'
bionic/libc/bionic/erand48.c:21: error: undefined reference to '_dorand48'

Any help would be appreciated. Thank you!

Alex Cohn

In your build, ld looks for static system libs (libc.a, libz.a, ...) while it should be looking for the shared versions of these libraries.

There is a -Bshared flag that can help, but to have full control of what is happening, I'd suggest the following linking step:

$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib \
-soname libffmpeg.so -nostdlib,noexecstack -Bsymbolic \
--whole-archive --no-undefined \
-o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a \
libavutil/libavutil.a libswscale/libswscale.a \
$PLATFORM/usr/lib/libc.so $PLATFORM/usr/lib/libm.so \
$PLATFORM/usr/lib/libz.so \
$PLATFORM/usr/lib/libdl.so $PLATFORM/usr/lib/liblog.so \
--dynamic-linker=/system/bin/linker \
$PREBUILT/lib/gcc/arm-linux-androideabi/4.8/libgcc.a

You seem to not need the executables, so you can add to your ./configure call

--disable-ffmpeg
--disable-ffprobe
--disable-ffserver

and remove the following lines:

--extra-ldflags
--extra-libs

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Compiling FFmpeg 3.1.1 for x86 using Android NDK

From Dev

FFMPEG 2.5.4 build for Android with NDK r10d

From Dev

Compiling C++11 sources for Android NDK

From Dev

Android NDK : Compiling different libraries for different architectures

From Dev

Android NDK -Error while compiling Library

From Dev

Compiling FFmpeg lib and add it to NDK sources on Windows8

From Dev

NDK64 and NDK32 r10

From Dev

How to solve this situation about ffmpeg with Android NDK

From Dev

rendering YUV ffmpeg frames in Android native ndk

From Dev

Compiling shared and static libraries into a shared library using the Android NDK

From Dev

Undefined reference error while compiling project (ANDROID NDK)

From Dev

NDK & Android Studio, compiling it crashes because of shared libraries

From Dev

Android NDK module not compiling (MIPS and MIPS64 are no longer supported)

From Dev

How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c

From Dev

How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c

From Dev

How to configure FFmpeg library with ndk r12 using windows 7 64 bit operating system for android

From Dev

Android NDK r10d error

From Dev

Android NDK r10d error

From Dev

Compiling ndk project with WebRTC

From Dev

video processing on android using ndk with ffmpeg and opencv is very slow

From Dev

need help configuring ffmpeg to decode raw AAC with android ndk

From Dev

ffmpeg - android ndk build assembler messages bad instruction

From Dev

NDK r10 b 32 bit or 64 bit or compile using both and how to achieve it

From Dev

Compiling NDK program with .lds script

From Dev

Compiling NDK program with .lds script

From Dev

Compiling android-ndk module with different STL than defined in Application.mk

From Dev

Compiling native android library with multiple c files using ndk build errors * No rule to make target

From Dev

Problems compiling object using arm-linux-androideabi-gcc and android ndk

From Dev

Compiling FFMPEG for ARM

Related Related

  1. 1

    Compiling FFmpeg 3.1.1 for x86 using Android NDK

  2. 2

    FFMPEG 2.5.4 build for Android with NDK r10d

  3. 3

    Compiling C++11 sources for Android NDK

  4. 4

    Android NDK : Compiling different libraries for different architectures

  5. 5

    Android NDK -Error while compiling Library

  6. 6

    Compiling FFmpeg lib and add it to NDK sources on Windows8

  7. 7

    NDK64 and NDK32 r10

  8. 8

    How to solve this situation about ffmpeg with Android NDK

  9. 9

    rendering YUV ffmpeg frames in Android native ndk

  10. 10

    Compiling shared and static libraries into a shared library using the Android NDK

  11. 11

    Undefined reference error while compiling project (ANDROID NDK)

  12. 12

    NDK & Android Studio, compiling it crashes because of shared libraries

  13. 13

    Android NDK module not compiling (MIPS and MIPS64 are no longer supported)

  14. 14

    How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c

  15. 15

    How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c

  16. 16

    How to configure FFmpeg library with ndk r12 using windows 7 64 bit operating system for android

  17. 17

    Android NDK r10d error

  18. 18

    Android NDK r10d error

  19. 19

    Compiling ndk project with WebRTC

  20. 20

    video processing on android using ndk with ffmpeg and opencv is very slow

  21. 21

    need help configuring ffmpeg to decode raw AAC with android ndk

  22. 22

    ffmpeg - android ndk build assembler messages bad instruction

  23. 23

    NDK r10 b 32 bit or 64 bit or compile using both and how to achieve it

  24. 24

    Compiling NDK program with .lds script

  25. 25

    Compiling NDK program with .lds script

  26. 26

    Compiling android-ndk module with different STL than defined in Application.mk

  27. 27

    Compiling native android library with multiple c files using ndk build errors * No rule to make target

  28. 28

    Problems compiling object using arm-linux-androideabi-gcc and android ndk

  29. 29

    Compiling FFMPEG for ARM

HotTag

Archive