您的位置:首页 > 其它

使用VS2008 在windows环境 编译Rtmpdump

2013-09-19 13:15 429 查看
转自:/article/8916451.html

折腾了好几天 终于在VS2008下面编译通过了Rtmpdump, 生成静态lib库,分享给大家。

http://rtmpdump.mplayerhq.hu/

源代码地址,这个开源组建是依赖zlib 和 OpenSSL的,所以要下载zlib和OpenSSL的安装版本。

1. 下载OpenSSL:

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

请下载
Win32 OpenSSL v1.0.0g16MB Installer
或者

Win64 OpenSSL v1.0.0g16MB Installer
安装的时候把lib和include文件直接安装到OpenSSL的安装目录就可以了。

2.下载Zlib

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

请下载
• Developer filesZip
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 /* HAVE_UNISTD_H -- this line is updated by ./configure */这里的 #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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: