Transferred from: http://blog.csdn.net/cjj198561/article/details/28955461
Compiling librtmp requires you to compile OpenSSL first, because Librtmp relies on OpenSSL
First compile OpenSSL:
Save the following as a shell script:
#!/bin/sh
version= "1.0.1h" #指明openssl的版本信息, such as the download is openssl-1.0.1h.tar.gz then for the fill 1.0.1h
sdkversion= "7.1" #指明ios SDK version number, the latest is 7.1, unclear classmate can ls/applications/xcode.app/contents/developer/platforms/ iphoneos.platform/developer/sdks/iphoneos7.1.sdk/, see if your IPHONEOS7.1.SDK is 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 isn't 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 "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."
Save script, add Execute permissions for script (chmod +x script name)
Run the script
No accident can be compiled successfully, if it fails, you can open the log file to see the reason for the failure.
After compiling successfully, the Lib file and include copy to your Librtmp directory (can create a new empty librtmp directory), in the Librtmp directory also write a shell script, the script is as follows:
#!/bin/sh
sdkversion= "7.1" #这里跟openssl的地方是一个意思
Currentpath= ' pwd '
archs= "i386 armv7 armv7s arm64"
Libpath= "${currentpath}/lib" #这里就是刚才拷贝过来的目录, do not modify, because the final generation of librtmp also placed below this
Includepath= "${currentpath}/include" #这里就是刚才拷贝过来的目录, do not modify, because the final generation of librtmp also placed below this
librtmprepo= "Git://git.ffmpeg.org/rtmpdump"
Buildpath= "${currentpath}/build"
Srcpath= "${CURRENTPATH}/SRC"
librtmp= "Librtmp.a"
Developer= ' Xcode-select-print-path '
if [!-D "$DEVELOPER"]; Then
echo "Xcode path isn't 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 have 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 have already installed, no need to install Openssl '
Else
Echo ' OpenSSL for iOS not found, would 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}/rtmpdump"
git clone ${librtmprepo} src/rtmpdump
CD "${srcpath}/rtmpdump/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}/rtmpdump
echo "Done."
Save Script
Run the script
The compilation was successful without an accident.
Compiling iOS version of Librtmp+openssl