轉載請註明出處: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