简体   繁体   中英

Building FFMpeg for Android NDK gives me .a instead of .so files

I'm a Mac user. I followed this tutorial : http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ to build FFMpeg for Android using NDK

I'm using FFMpeg 2.1 and NDK r9 .

Here is my build_android.sh file in my FFMepg folder which is in my $NDK/sources folder :

#!/bin/bash

NDK=$HOME/Desktop/adt/android-ndk
SYSROOT=$NDK/platforms/android-8/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-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
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm"
build_one

Evrything is compiling fine but at the end I get .a files whereas in the tutorial I should get .so files.

What is wrong with what I did ? The only thing that changes is :

TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64

which is :

TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

in the tutorial.

I tried your approach but not suceeded. Change to --disable-shared and enable-static

After your make install add following

$TOOLCHAIN/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$TOOLCHAIN/bin/arm-linux-androideabi-ld -rpath-link=$SYSROOT/usr/lib -L$SYSROOT/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,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 -lx264  --warn-once  --dynamic-linker=/system/bin/linker $TOOLCHAIN/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a

This worked for me! This approach is building .a and linking all .a to .so file. Change libffmpeg.so to any name you want.

You should use the make that comes with NDK:

...
$NDK/prebuilt/darwin-x86_64/bin/make clean
$NDK/prebuilt/darwin-x86_64/bin/make
$NDK/prebuilt/darwin-x86_64/bin/make install

BTW, you can put ffmpeg sources anywhere, no need to keep it under NDK/sources .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM