当--sysroot指向另一个目录时,如何让FFmpeg找到已安装的库?

时间:2012-02-03 04:53:31

标签: gcc build ffmpeg android-ndk sh

我一直在这方面,几天来。我正在尝试使用libmp3lame构建FFmpeg以用于Android应用程序。构建脚本设置一个--sysroot标志,指向以Android可以使用它们的方式构建这些库所需的Android NDK目录。

当我将标志添加到--enable-libmp3lame时出现问题;我在构建启动期间得到ERROR: libmp3lame >= 3.98.3 not found。我知道LAME和它的库已经安装,因为我可以手动运行./configure --enable-libmp3lame并且配置启动顺利,并显示为此构建启用了libmp3lame。但是,这样的构建根本无法满足我的需求,因为我需要Android NDK来完成一些工作。

我已经将问题跟踪到这个构建脚本声明sysroot的事实,并且通过一些研究,我尝试将-Luser/include-L/user/include添加到额外的cflags和ldflags (我读过的是gcc的默认搜索位置)。我也尝试了其他几个方面,但我相信有人可以帮助解决这个具体问题。整个构建脚本如下:

额外信息:

  • 构建操作系统:Ubuntu 11.10
  • FFmpeg Ver:最新的git
  • LAME Ver:3.9.x
  • Android NDK:r7

build.sh

#!/bin/bash

if [ "$NDK" = "" ]; then
    echo NDK variable not set, assuming ${HOME}/android-ndk
    export NDK=${HOME}/android-ndk
fi

SYSROOT=$NDK/platforms/android-3/arch-arm
# Expand the prebuilt/* path into the correct one
TOOLCHAIN=`echo $NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86`
export PATH=$TOOLCHAIN/bin:$PATH

rm -rf build/ffmpeg
mkdir -p build/ffmpeg
cd ffmpeg

# Don't build any neon version for now
for version in armv5te armv7a; do

        DEST=../build/ffmpeg
        FLAGS="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm"
        FLAGS="$FLAGS --sysroot=$SYSROOT"
        FLAGS="$FLAGS --soname-prefix=/data/data/net.smartnotes/lib/"
        FLAGS="$FLAGS --enable-shared --disable-symver"
        FLAGS="$FLAGS --enable-small --optimization-flags=-O2"
        FLAGS="$FLAGS --disable-everything --enable-protocol=file"
        FLAGS="$FLAGS --enable-libmp3lame --enable-encoder=nellymoser"

        case "$version" in
                neon)
                    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon"
                    EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"
                    # Runtime choosing neon vs non-neon requires
                    # renamed files
                    ABI="armeabi-v7a"
                    ;;
                armv7a)
                    # I have tried many things here.
                    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp"
                    EXTRA_LDFLAGS=""
                    ABI="armeabi-v7a"
                    ;;
                *)
                    # I have tried many things here.
                    EXTRA_CFLAGS="-Luser/include"
                    EXTRA_LDFLAGS=""
                    ABI="armeabi"
                    ;;
        esac
        DEST="$DEST/$ABI"
        FLAGS="$FLAGS --prefix=$DEST"

        mkdir -p $DEST
        echo $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" > $DEST/info.txt
        ./configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" | tee $DEST/configuration.txt
        [ $PIPESTATUS == 0 ] || exit 1
        make clean
        make -j4 || exit 1
        make install || exit 1

done

2 个答案:

答案 0 :(得分:1)

为什么不尝试将由'make install'创建的所有libmp3lame文件复制到脚本将查找它们的相关目录,而不是更改包含路径。插入ECHO语句以找出PATH / CFLAGS / LDFLAGS在出现错误时的确切位置,并将文件复制到那里以便找到它们。

答案 1 :(得分:1)

我看到你正在使用位于的项目 http://bambuser.com/opensource

我遇到了同样的问题并且这样解决了:

  1. 使用https://github.com/intervigilium/liblame
  2. 编译lame for android
  3. 这是来自“bambuser.com”的原始diff与我使用的build.sh之间的小3c3,6 < export NDK=${HOME}/downloads/android-ndk # r8d --- > if [ "$NDK" = "" ]; then > echo NDK variable not set, assuming ${HOME}/android-ndk > export NDK=${HOME}/android-ndk > fi 15,16c18 < #for version in armv5te armv7a; do < for version in armv7a; do --- > for version in armv5te armv7a; do 24c26 < FLAGS="$FLAGS --disable-everything --enable-libmp3lame" --- > FLAGS="$FLAGS --disable-everything"

    liblame/jni/lame
  4. 来自“intervigilium”项目的
  5. 将文件夹PATH_TO_NDK/platforms/android-3/arch-arm/usr/include复制到liblame/libs/armeabi-v7a/liblame.so

  6. 从“intervigilium”项目复制PATH_TO_NDK/platforms/android-3/arch-arm/usr/libslibmp3lame.so RENAME build.sh
  7. 最后运行install prefix ../build/ffmpeg/armeabi-v7a source path /home/samuele/downloads/ffmpeg/ffmpeg-android/ffmpeg C compiler arm-linux-androideabi-gcc ARCH arm (generic) big-endian no runtime cpu detection no ARMv5TE enabled yes ARMv6 enabled yes ARMv6T2 enabled yes ARM VFP enabled yes IWMMXT enabled no NEON enabled no debug symbols yes strip symbols yes optimizations small static yes shared yes postprocessing support no new filter support yes network support yes threading support pthreads SDL support no Sun medialib support no AVISynth enabled no frei0r enabled no libdc1394 support no libdirac enabled no libfaac enabled no libgsm enabled no **libmp3lame enabled yes** libnut enabled no libopencore-amrnb support no libopencore-amrwb support no libopencv support no libopenjpeg enabled no librtmp enabled no libschroedinger enabled no libspeex enabled no libtheora enabled no libvorbis enabled no libvpx enabled no libx264 enabled no libxavs enabled no libxvid enabled no zlib enabled no bzlib enabled no Enabled decoders: Enabled encoders: mpeg2video nellymoser Enabled hwaccels: Enabled parsers: Enabled demuxers: Enabled muxers: Enabled protocols: Enabled filters: buffer Enabled bsfs: Enabled indevs: Enabled outdevs: License: LGPL version 2.1 or later Creating config.mak and config.h... libavutil/avconfig.h is unchanged
  8. 你应该没事:

    --disable-everything
  9. 请注意,我仍然需要测试生成的FFmpeg构建。 说实话,现在我必须学习如何在我的App中使用它...;)

    编辑:我尝试删除build并使用大量编码器,解码器等构建OK,但{{1}}目录增加到~40MB。