转载请注明出处:http://www.cnblogs.com/fpzeng/p/3202344.htmlhtml
系统版本:OS X 10.8ios
librtmp link时须要openssl,在iOS上编译openssl请参考如下脚本:https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh,假设openssl/*.h头文件放于git
/a/b/c/openssl/include路径下,libcrypto.a和libssl.a库文件i386版本存放于/a/b/c/openssl/ios/libs/ios_i386路径下,libcrypto.a和libssl.a库文件armv7版本存放于/a/b/c/openssl/ios/libs/ios_armv7路径下。github
首先获取librtmp代码:app
git clone git://git.ffmpeg.org/rtmpdump
在rtmpdump中就有librtmp代码了,能够看到librtmp/Makefile文件已经存在了,咱们须要作的就是export相关变量就好了。其中须要处理CROSS_COMPILE、XCFLAGS、XLDFLAGS三个变量。优化
cd rtmpdump/librtmp export CROSS_COMPILE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ export XCFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -I/a/b/c/openssl/ios/include -arch i386" export XLDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/a/b/c/openssl/ios/libs/ios_i386 -arch i386 "
make SYS=darwin
export CROSS_COMPILE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ export XCFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -I/a/b/c/openssl/ios/include -arch armv7'
export XLDFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/a/b/c/openssl/ios/libs/openssl/ios_armv7 -arch armv7'
make SYS=darwin
若是须要调试,请将librtmp/Makefile中设置优化选项产生debug信息。ui
OPT=-O0 CFLAGS=-Wall -g $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF) LDFLAGS=$(XLDFLAGS) -g
其中,-O0能减小编译时间并产生调试信息。而且在编译和连接选项中添加-g选项产生debug symbol。spa
假设librtmp/*.h头文件在/a/b/c/librtmp/include路径下,librtmp.a在/a/b/c/librtmp/libs/路径下。debug
执行配置时,添加选项开启librtmp而且指定头文件和连接库路径:调试
./configure --enable-librtmp --extra-cflags=-I/a/b/c/librtmp/include --extra-ldflags=-L/a/b/c/librtmp/libs/
此时,提示错误:
ERROR: librtmp not found
查看日志文件config.log:
check_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
ERROR: librtmp not found
ffmpeg尝试在检查librtmp时运行pkg-config,请将
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
修改成
enabled librtmp