Compiling FFmpeg lib and add it to NDK sources on Windows8

10,166

Solution 1

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

Solution 2

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.

Share:
10,166
Nativ
Author by

Nativ

Updated on July 25, 2022

Comments

  • Nativ
    Nativ almost 2 years

    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
    [email protected] 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
    Nativ over 10 years
    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"
  • Alex Bitek
    Alex Bitek over 10 years
    @powerX Android NDK r9b
  • Nativ
    Nativ over 10 years
    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
    Nativ over 10 years
    FTI - added script results on my machine in the body of the question
  • Alex Bitek
    Alex Bitek over 10 years
    @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 stackoverflow.com/a/12144419/313113
  • Mycoola
    Mycoola over 9 years
    This Solution for linux not for windows
  • Mycoola
    Mycoola over 9 years
    The question for Compiling FFmpeg lib and add it to NDK sources on Windows8 not linux