简体   繁体   English

为Android NDK构建FFMpeg给我.a而不是.so文件

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

I'm a Mac user. 我是Mac用户。 I followed this tutorial : http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ to build FFMpeg for Android using NDK 我遵循了本教程: http ://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/以使用NDK为Android构建FFMpeg

I'm using FFMpeg 2.1 and NDK r9 . 我正在使用FFMpeg 2.1NDK r9

Here is my build_android.sh file in my FFMepg folder which is in my $NDK/sources folder : 这是我的build_android.sh文件夹中的build_android.sh文件,该文件位于$NDK/sources文件夹中:

#!/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. Evrything可以很好地编译,但是最后我得到了.a文件,而在教程中我应该得到.so文件。

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 更改为--disable-sharedenable-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. 这种方法是构建.a并将所有.a链接到.so文件。 Change libffmpeg.so to any name you want. libffmpeg.so更改为所需的任何名称。

You should use the make that comes with NDK: 您应该使用make自带的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 . 顺便说一句,您可以将ffmpeg源放置在任何地方,而无需将其保留在NDK/sources

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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