ios - 使用 librtmp 错误 : librtmp not found 编译 FFmpeg

标签 ios compilation ffmpeg xcode5 rtmp

环境:Mac OS X 10.9.2,Xcode 5.1。

我已经成功编译了librtmp、libogg和libspeex,它们在名为fat-librtmp的目录中。 , fat-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脚本,但仍然出现同样的错误!有人可以告诉我为什么以及如何解决它吗?

最佳答案

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

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

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

关于ios - 使用 librtmp 错误 : librtmp not found 编译 FFmpeg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23472138/

相关文章:

c - GCC 和 Clang 解析器真的是手写的吗?

video - ffmpeg:如何在视频末尾添加帧或黑色?

video - 使用 ffmpeg 搜索电影原子

ios - "Connect via network"无线调试不工作 Xcode 9

android - 蓝牙设备可以向 WiFi 发送消息吗?

compilation - 无法在gcc(OS X)上使用curses进行编译)

visual-c++ - 在Windows 7中编译Libpng或获取Libpng12.dll(并了解如何在VS中链接.DLL)

php - FFmpeg libavfilter水印?

objective-c - 如何刷新 NSLog 的缓冲区?

ios - 将特定注释的数据带到下一个 View