使用librtmp编译FFmpeg错误:未找到librtmp

时间:2014-05-05 12:11:07

标签: ios compilation ffmpeg xcode5 rtmp

环境:Mac OS X 10.9.2,Xcode 5.1。

我已经成功编译了librtmp,libogg和libspeex,它们位于名为fat-librtmpfat-liboggfat-libspeex的目录中,然后我运行下面的shell脚本将它们编译成FFmpeg :

#!/bin/sh

# OS X Mavericks, Xcode 5.1

set -ex

VERSION="2.2.2"
CURRPATH=`pwd`
DSTDIR="ffmpeg-built"
SCRATCH="scratch"
LIBRTMP=$CURRPATH/librtmp
ARCHS="i386 x86_64 armv7 armv7s arm64"

CONFIGURE_FLAGS="--enable-shared \
                --disable-doc \
                --disable-stripping \
                --disable-ffmpeg \
                --disable-ffplay \
                --disable-ffserver \
                --disable-ffprobe \
                --disable-decoders \
                --disable-encoders \
                --disable-protocols \
                --enable-protocol=file \
                --enable-protocol=rtmp \
                --enable-librtmp \
                --enable-encoder=flv \
                --enable-decoder=flv \
                --disable-symver \
                --disable-asm \
                --enable-cross-compile"

rm -rf $DSTDIR
mkdir $DSTDIR

if [ ! `which yasm` ]; then
    if [ ! `which brew` ]; then
        ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
    fi
    brew install yasm
fi

if [ ! `which gas-preprocessor.pl` ]; then
    curl -3L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl -o /usr/local/bin/gas-preprocessor.pl
    chmod +x /usr/local/bin/gas-preprocessor.pl
fi

if [ ! -e ffmpeg-$VERSION.tar.bz2 ]; then
    curl -O http://www.ffmpeg.org/releases/ffmpeg-$VERSION.tar.bz2
fi

tar jxf ffmpeg-$VERSION.tar.bz2


export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

for ARCH in $ARCHS; do
    mkdir -p $DSTDIR/$SCRATCH/$ARCH
    cd $DSTDIR/$SCRATCH/$ARCH

    CFLAGS="-arch $ARCH"
    if [ $ARCH == "i386" -o $ARCH == "x86_64" ]; then
        PLATFORM="iPhoneSimulator"
        CFLAGS="$CFLAGS -mios-simulator-version-min=6.0"
    else
        PLATFORM="iPhoneOS"
        CFLAGS="$CFLAGS -mios-version-min=6.0"
        if [ $ARCH == "arm64" ]; then
            EXPORT="GASPP_FIX_XCODE5=1"
        fi
    fi

    XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
    CC="xcrun -sdk $XCRUN_SDK clang"
    CFLAGS="$CFLAGS -I$LIBRTMP/include"
    CXXFLAGS="$CFLAGS"
    LDFLAGS="$CFLAGS -L$LIBRTMP/lib"

    $CURRPATH/ffmpeg-$VERSION/configure \
    --target-os=darwin \
    --arch=$ARCH \
    --cc="$CC" \
    $CONFIGURE_FLAGS \
    --extra-cflags="$CFLAGS" \
    --extra-cxxflags="$CXXFLAGS" \
    --extra-ldflags="$LDFLAGS" \
    --prefix=$CURRPATH/$DSTDIR/$ARCH

    make -j3 install $EXPORT

    cd $CURRPATH
done

rm -rf $DSTDIR/$SCRATCH
mkdir -p $DSTDIR/lib
cd $DSTDIR/$ARCH/lib
LIBS=`ls *.a`
cd $CURRPATH

for LIB in $LIBS; do
    lipo -create `find $DSTDIR -name $LIB` -output $DSTDIR/lib/$LIB
done

cp -rf $DSTDIR/$ARCH/include $DSTDIR

for ARCH in $ARCHS; do
    rm -rf $DSTDIR/$ARCH
done

不幸的是,config.log显示:

check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
pkg-config --exists --print-errors librtmp
Package librtmp was not found in the pkg-config search path.
Perhaps you should add the directory containing `librtmp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'librtmp' found
ERROR: librtmp not found

我用谷歌搜索并知道configure包含一行enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket,这可能是错误的。对?有人可以帮我解决吗?

2014/06/10更新

我认为这是关于pkgconfig或其他什么的,所以我在librtmp.pc创建了一个名为/usr/local/lib/pkgconfig的文件,其中包含以下文字:

prefix=/usr/local/librtmp
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: librtmp
Description: RTMP implementation
Version: v2.3
Requires:
URL: http://rtmpdump.mplayerhq.hu
Libs: -L${libdir} -lrtmp -lz
Cflags: -I${includedir}

此外,我已将内置librtmp移至/usr/local。完成上述操作后,我再次运行shell脚本,但仍然出现同样的错误!有人能告诉我为什么以及如何解决它?

1 个答案:

答案 0 :(得分:0)

以下链接在构建ffmpeg时提供了一些见解。

https://trac.ffmpeg.org/wiki/CompilationGuide/Generic

检查LD_LIBRARY_PATH环境变量是否设置正确。