天天看點

使用VS2008 在windows環境 編譯Rtmpdump

折騰了好幾天 終于在VS2008下面編譯通過了Rtmpdump, 生成靜态lib庫,分享給大家。

http://rtmpdump.mplayerhq.hu/

源代碼位址,這個開源組建是依賴zlib 和 OpenSSL的,是以要下載下傳zlib和OpenSSL的安裝版本。

1. 下載下傳OpenSSL:

http://www.slproweb.com/products/Win32OpenSSL.html

請下載下傳 

Win32 OpenSSL v1.0.0g 16MB Installer

或者

Win64 OpenSSL v1.0.0g 16MB Installer

安裝的時候把lib和include檔案直接安裝到OpenSSL的安裝目錄就可以了。

2.下載下傳Zlib

http://gnuwin32.sourceforge.net/packages/zlib.html

請下載下傳 

• Developer files Zip

71569

20 July 2005

def79b244cd1e1eec8fd221bd8d2a361

3. 下載下傳Rtmpdump最新代碼 目前是2.4版本, 需要一個git windows版本的工具拉代碼

http://code.google.com/p/msysgit/downloads/list,

下載下傳完安裝後運作,直接指令行裡邊輸入

  • git clone git://git.ffmpeg.org/rtmpdump
  • 代碼就已經拉下來了,放在C:\Users\xxx\ 目錄裡邊

4.用vs2008建立一個靜态類庫工程, 把 C:\Users\xxx\rtmpdump\librtmp\下的所有.h .c 檔案copy到 建立工程的目錄下, 并且在vs2008工程裡邊添加這些檔案。

5. 在vs2008 tools- option - projects and solutions - vc++ directories 裡邊,把OpenSSL和Zlib的 include和lib路徑都添加進去。

6.首先編譯檔案hashswf.c, 您一定會得到錯誤找不到 stdint.h 頭檔案 這個檔案網上有 搜尋一個,然後放在OpenSSL的include目錄裡邊,這個錯誤可以fix掉了。 或者可以看我的下一條博文,我會把它貼出來

7.然後的錯誤是 fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory 輕按兩下這個錯誤 直接跳轉到錯誤的line, 然後把 #if 1           這裡的 #if 1 改成 #if0,讓編譯器跳過這塊, 可以fix掉這個錯誤

這個時候您應該可以成功編譯過hashswf.c檔案了。

8.然後編譯amf.c檔案, 您會得到錯誤  error C3163: '_vsnprintf': attributes inconsistent with previous declaration

1>        c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(350) : see declaration of '_vsnprintf'

打開rtmp_sys.h這個檔案 然後把 第34行的定義 #define vsnprintf _vsnprintf 注釋掉, 因為這個定義windows已經定義過了。

到這個時候 您應該可以成功編譯Rtmpdump組建了,接下來就是使用了 先貼一些測試代碼,如果後面有空,我會把使用的一些心得發上來與大家分享。

 RTMP *rtmp; 

    char uri[]="rtmp://xxx.xxx.xxx/xxx/"; 

    rtmp = RTMP_Alloc(); 

if(rtmp == NULL)

return 0;

    RTMP_Init(rtmp); 

    int err = RTMP_SetupURL(rtmp, (char*)uri); 

if(err < 0)

return 0;

    RTMP_EnableWrite(rtmp); 

    RTMP_Connect(rtmp, NULL); 

if(err < 0)

return 0;

    RTMP_ConnectStream(rtmp,0); 

if(err < 0)

return 0;