问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

有大侠在ios下编译过librtmp的库文件么

发布网友 发布时间:2022-05-13 04:07

我来回答

1个回答

热心网友 时间:2023-11-17 18:31

编译librtmp需要先编译openssl,因为librtmp依赖openssl

首先编译openssl:

把以下内容保存为shell脚本:

#!/bin/sh

VERSION="1.0.1h" #指明openssl的版本信息,比如下载的是openssl-1.0.1h.tar.gz那么对于就填写1.0.1h
SDKVERSION="7.1" #指明ios sdk的版本号,目前最新的是7.1,不清楚的同学可以 ls /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/ 一下看看自己的iPhoneOS7.1.sdk是不是7.1

CURRENTPATH=`pwd`
ARCHS="i386 armv7 armv7s arm64"
BUILDPATH="${CURRENTPATH}/build"
LIBPATH="${CURRENTPATH}/lib"
INCLUDEPATH="${CURRENTPATH}/include"
SRCPATH="${CURRENTPATH}/src"
LIBSSL="libssl.a"
LIBCRYPTO="libcrypto.a"
DEVELOPER=`xcode-select -print-path`

if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

set -e
if [ ! -e openssl-${VERSION}.tar.gz ]; then
echo "Downloading openssl-${VERSION}.tar.gz"
curl -O http://www.openssl.org/source/openssl-${VERSION}.tar.gz
else
echo "Using openssl-${VERSION}.tar.gz"

# Remove the source directory if already exist
rm -rf "${SRCPATH}/openssl-${VERSION}"
fi

mkdir -p "${SRCPATH}"
mkdir -p "${BUILDPATH}"
mkdir -p "${LIBPATH}"
mkdir -p "${INCLUDEPATH}"

tar zxf openssl-${VERSION}.tar.gz -C "${SRCPATH}"
cd "${SRCPATH}/openssl-${VERSION}"

LIBSSL_REPO=""
LIBCRYPTO_REPO=""

for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
PLATFORM="iPhoneOS"
fi
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"

echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}"
echo "Please stand by..."

export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"

OUTPATH="${BUILDPATH}/openssl-${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
mkdir -p "${OUTPATH}"
LOG="${OUTPATH}/build-openssl-${VERSION}.log"

if [[ "$VERSION" =~ 1.0.0. ]]; then
./Configure BSD-generic32 --openssldir="${OUTPATH}" > "${LOG}" 2>&1
else
./Configure iphoneos-cross --openssldir="${OUTPATH}" > "${LOG}" 2>&1
fi

# add -isysroot to CC=
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/Platforms/${PLATFORM}.platform/Developer/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 !" "Makefile"

make >> "${LOG}" 2>&1
make install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1

LIBSSL_REPO+="${OUTPATH}/lib/${LIBSSL} "
LIBCRYPTO_REPO+="${OUTPATH}/lib/${LIBCRYPTO} "
done

echo "Build library..."
lipo -create ${LIBSSL_REPO}-output ${LIBPATH}/${LIBSSL}
lipo -create ${LIBCRYPTO_REPO}-output ${LIBPATH}/${LIBCRYPTO}

cp -R ${BUILDPATH}/openssl-iPhoneSimulator${SDKVERSION}-i386.sdk/include/openssl ${INCLUDEPATH}/
echo "Building done."
echo "Cleaning up..."
rm -rf ${SRCPATH}/openssl-${VERSION}
echo "Done."

保存脚本,添加脚本的执行权限(chmod +x 脚本名称)

运行脚本
不出意外是可以编译成功的,如果失败,可以以打开那个log文件,查看失败原因。

编译成功以后,把lib文件和include拷贝到你的librtmp目录(可以新建一个空得librtmp目录),在librtmp目录里面同样写一个shell脚本,脚本如下:

#!/bin/sh

SDKVERSION="7.1" #这里跟openssl的地方是一个意思

CURRENTPATH=`pwd`
ARCHS="i386 armv7 armv7s arm64"

LIBPATH="${CURRENTPATH}/lib" #这里就是刚才拷贝过来的目录,不要修改,因为librtmp最后生成的也放到了这个下面
INCLUDEPATH="${CURRENTPATH}/include" #这里就是刚才拷贝过来的目录,不要修改,因为librtmp最后生成的也放到了这个下面

LIBRTMPREPO="git://git.ffmpeg.org/rtmpmp"
BUILDPATH="${CURRENTPATH}/build"
SRCPATH="${CURRENTPATH}/src"
LIBRTMP="librtmp.a"
DEVELOPER=`xcode-select -print-path`

if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

# Check whether openssl has already installed on the machine or not.
# libcrypt.a / libssl.a

set -e
echo 'Check openssl installation'
if [ -f "${LIBPATH}/libcrypto.a" ] && [ -f "${LIBPATH}/libssl.a" ] && [ -d "${INCLUDEPATH}/openssl" ]; then
echo 'Openssl for iOS has already installed, no need to install openssl'
else
echo 'Openssl for iOS not found, will install openssl for iOS'
./build-libssl.sh
echo 'Succeeded to install openssl'
fi

# Download librtmp source code from git repository
# We assuem the user already installed git client.
echo 'Clone librtmp git repository'

# Remove the directory if already exist
rm -rf "${SRCPATH}/rtmpmp"

git clone ${LIBRTMPREPO} src/rtmpmp
cd "${SRCPATH}/rtmpmp/librtmp"

LIBRTMP_REPO=""

for ARCH in ${ARCHS}
do
if [ "${ARCH}" == "i386" ];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"

echo "Building librtmp for ${PLATFORM} ${SDKVERSION} ${ARCH}"
echo "Please wait..."

# add arch to CC=
sed -ie "s!AR=\$(CROSS_COMPILE)ar!AR=/usr/bin/ar!" "Makefile"
sed -ie "/CC=\$(CROSS_COMPILE)gcc/d" "Makefile"
echo "CC=\$(CROSS_COMPILE)gcc -arch ${ARCH}" >> "Makefile"

export CROSS_COMPILE="${DEVELOPER}/usr/bin/"
export XCFLAGS="-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 -I${INCLUDEPATH} -arch ${ARCH}"

if [ "${ARCH}" == "i386" ];
then
export XLDFLAGS="-L${LIBPATH} -arch ${ARCH}"
else
export XLDFLAGS="-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 -L${LIBPATH} -arch ${ARCH}"
fi
OUTPATH="${BUILDPATH}/librtmp-${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
mkdir -p "${OUTPATH}"
LOG="${OUTPATH}/build-librtmp.log"

make SYS=darwin >> "${LOG}" 2>&1
make SYS=darwin prefix="${OUTPATH}" install >> "${LOG}" 2>&1
make clean >> "${LOG}" 2>&1

LIBRTMP_REPO+="${OUTPATH}/lib/${LIBRTMP} "
done

echo "Build universal library..."
lipo -create ${LIBRTMP_REPO}-output ${LIBPATH}/${LIBRTMP}

mkdir -p ${INCLUDEPATH}
cp -R ${BUILDPATH}/librtmp-iPhoneSimulator${SDKVERSION}-i386.sdk/include/ ${INCLUDEPATH}/

echo "Building done."
echo "Cleaning up..."

rm -rf ${SRCPATH}/rtmpmp
echo "Done."

保存脚本

运行脚本

不出意外就编译成功了。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
vivo y18l 死机卡在开机界面 vivoy18l手机频繁黑屏死机怎么办? vivo y18l 死机了怎么办 vivoY18l黑屏死机解决办法 vivo y18l刷机很久都开不了机怎么? 湖北自考专升本会有学籍吗? 湖北自考专升本后可以考研吗 湖北自考申请毕业证的时间在什么时候 湖北自考专升本学历怎么查询 湖北自考专升本为什么没有学籍 会计毕业论文结束语 在哪看微信状态 matlab mbuild配置 gui生成的exe不能运行 android studio 编译完成,点击运行出现please select android SDK 上海启林投资为什么很多产品不公布净值 计算机国家四级好考吗?报考有要求吗?一定要过了二级才能考吗? 8岁脚臭怎么办网上说用米醋泡脚有用吗? 为什么抖音自己美颜瘦脸 脚臭可以用加了醋的热水泡脚吗 用白醋泡脚能治脚臭吗? 08年姓蔡男孩子取什么名字 脚臭可以用白醋泡脚吗 姓蔡女孩子名字 我想给儿子起名蔡子钊什么意思 我姓蔡,想给快出生的孩子取个名字,还不知道是男孩女孩呢,第3个字是睿,请大家 蔡”女孩子,叫什么名字好 给男娃起名字。。蔡子。,,什么好 请大家帮我想个好听一点的名字,本人姓蔡,想改个好听一些的名字,韩国的,浪漫点的,有诗意点的都行! 我的堂弟要取名字,要蔡子什么?后面那个字要带有金字旁的,我都不知道要用什么字,希望大家帮帮忙!!! 公司在存在无底薪如何申请劳动仲裁 分公司怎么申请劳动仲裁 怎么修改电脑图标大小 幼儿园小朋友读书计划表怎么做 1960年2元旧版人民币值多少钱? 1960年2元纸币现在市值多少? 微信公众号能查看我的个人信息吗 例如我的 手机号等- 问一问 ...台式电脑能找到别人家的WiFi却找不到自己家的WiFi?手机,笔记本都行... 怎么卸载io14 ios14beta4怎么删除? 莫斯科是不是在俄罗斯? 罗马,雅典,华盛顿,维也纳,莫斯科分别在什么国家 衣柜的柜的笔顺怎么写 躺的笔顺怎么写 架的笔顺笔画顺序 什么药物与海参的功效相同 碗的笔顺笔画顺序 海参的功效与作用,海参的营养价值和什么一样 海参功效与作用用什么可以代替 谁能归纳一下NBA有外号的球员的名字?