8

I've seen some articles about how to compile and uses FFmpeg for Android.

These are 2 good examples - example1 and example2

Unfortunately, non off them, or others I found helped me. In those two examples a build_android.sh is created and configure the FFmpeg's configuraion file and call to make. Every time when I'm running the script I'm getting the following error:

c:\android\development\android-ndk-r9\sources\ffmpeg>sh build_android.sh
c:/android/development/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows-x86_64/arm-linux-androideabi/bin/bin/arm-linux-androideabi-gcc is un

able to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
Makefile:2: config.mak: No such file or directory
Makefile:49: /common.mak: No such file or directory
Makefile:92: /libavutil/Makefile: No such file or directory
Makefile:92: /library.mak: No such file or directory
Makefile:169: /doc/Makefile: No such file or directory
Makefile:170: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'.  Stop.
Makefile:2: config.mak: No such file or directory

If someone encountered and solved this issue it'll be much appreciated!

After trying the suggested script I ran into a new problem that I couldn't solved, this is the output of the script:

.... Enabled components list....

In the end of the list I got the following:

Enabled indevs: dv1394 v4l2i fbdev

Enabled outdevs: fbdev v4l2

License: LGPL version 2.1 or later Creating config.mak, config.h, and doc/config.texi...

WARNING: C:/android/development/android-ndk-r9/toolchains/arm-linux-androideabi- 4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config not found, libr ary detection may fail. make: *** No rule to make target libavfilter/libavfilter.so', needed by all-ye s'. Stop. make: *** No rule to make target install-libavfilter-shared', needed by instal l-libs-yes'. Stop.

Nativ
  • 3,092
  • 6
  • 38
  • 69
  • Hi, I am trying to build ffmpeg the same way and process ending up with following errors: Makefile:2: config.mak: No such file or directory Makefile:49: /common.mak: No such file or directory Makefile:92: /libavutil/Makefile: No such file or directory Makefile:92: /library.mak: No such file or directory Makefile:169: /doc/Makefile: No such file or directory Makefile:170: /tests/Makefile: No such file or directory How to fix this issue??? – Wikki Feb 12 '14 at 08:48
  • seems to have been answered elsewhere: _[How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c](http://stackoverflow.com/questions/23683518/how-to-compile-ffmpeg-2-2-2-on-windows-with-cygwin-and-android-ndk-r9c)_ – Alex Cohn Sep 28 '14 at 18:10

2 Answers2

8

Can you paste what's in your build_android.sh file which you've copied inside the FFmpeg directory?

I've got the same error when one of the variables defined at the start of the script where set incorrectly. Check to see if your NDK or SYSROOT or TOOLCHAIN variables are set to a valid path!

I've tried using the following steps and it worked for me:

1) Download FFmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

2) Create a file called build_android.sh inside the FFmpeg directory

cd ffmpeg; touch build_ffmpeg_for_android.sh;

3) Add the following content to the file

#!/usr/bin/env bash

NDK=$HOME/Software/Android/android-ndk-r10/
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make -j4
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one

4) Make the script executable

chmod +x build_ffmpeg_for_android.sh

5) Start the build of FFmpeg for Android (ARM)
(run the script with Bash, i.e. /usr/bin/bash not /usr/bin/sh)

./build_ffmpeg_for_android.sh

Alex Bitek
  • 6,529
  • 5
  • 47
  • 77
  • 2
    Against which NDK version do you work? My NDK version is r9 and I keep getting in the end of the script error message: "arm-linux-androideabi-pkg-config not found, library detection may faile", and then "nonexecstack: unknown -z option" – Nativ Nov 11 '13 at 09:22
  • 1
    @powerX Android NDK r9b – Alex Bitek Nov 11 '13 at 09:23
  • thank you for the preciouse help, the above will be the answer probably. Even so I still have this problem and I think that it related to the fact that in my ndk folder I don't have "linux-x86_64" inside the "prebuilt" folder(I changed it in my script to "windows-x86_64") – Nativ Nov 11 '13 at 09:46
  • FTI - added script results on my machine in the body of the question – Nativ Nov 11 '13 at 09:57
  • @powerX Unfortunately the Windows Android NDK doesn't have **arm-linux-androideabi-pkg-config**. Does your Cygwin installation have **pkg-config** installed? It worked for me on a GNU/Linux system with only that installed... I think one of the above is required for building FFmpeg. As an alternative I suggest you look at this answer http://stackoverflow.com/a/12144419/313113 – Alex Bitek Nov 11 '13 at 22:02
  • This Solution for linux not for windows – Mycoola Dec 14 '14 at 10:17
  • The question for Compiling FFmpeg lib and add it to NDK sources on Windows8 not linux – Mycoola Dec 16 '14 at 11:44
1

I was getting the same errors as @powerX and I was able to solve the issue using a different method from @dZkF9RWJT6wN8ux.

Though I am using Ubuntu 13.10, I hope you find my answer helpful. With android NDK r9 and FFMPEG 2.2 "Muybridge" release, I was finally able to accomplish the third step entitled "Build FFMPEG" from @powerX example1 link: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

I finally fixed this by changing the SYSROOT variable in the build_android.sh file to point to ".../android-19/arch-arm" instead of .../android-9/arch-arm".

Hope this helps.

Dick Lucas
  • 12,289
  • 14
  • 49
  • 76