第一、下载 librtmp (rtmpdump)源码,把 librtmp目录下的 非 .h 和 非 .c 文件 全部删除掉
第二、用 Microsotf Visual Studio 2017 创建一个 静态库 (lib)项目,将librtmp目录下的所有 .h 和 .c 文件 加载到 此 项目中。
第三、打开 rtmp_sys.h 文件 ,找到并注释掉下面的三句 语句:
#ifdef _WIN32
#include
#include
#ifdef _MSC_VER /* MSVC */
**//#define snprintf _snprintf //此句注释掉**
#define strcasecmp stricmp
#define strncasecmp strnicmp
**//#define vsnprintf _vsnprintf //此句注释掉**
#endif
#define GetSockError() WSAGetLastError()
#define SetSockError(e) WSASetLastError(e)
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
**//下面这句注释掉
//#define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */**
#define sleep(n) Sleep(n*1000)
#define msleep(n) Sleep(n)
#define SET_RCVTIMEO(tv,s) int tv = s*1000
#else /* !_WIN32 */
第四、打开rtmp.c 文件 找到 static struct urlopt { 这句
在其前面 添加一句 :
typedef long off_t;
第五、在 项目 – 属性 – c\c++ – 预处理器 — 预处理器定义中
添加以下宏:
NO_CRYPTO
_CRT_NONSTDC_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS
其中 NO_CRYPTO 是不打开openssl
第六、在 项目 – 属性 – c\c++ – 预编译头 中 设置成 不使用预编译头
第七、 编译、链接 通过
另:
在使用 librtmp.lib 时,如果用的是Debug ,会出现
error LNK2001: 无法解析的外部符号 _netstackdump
error LNK2001: 无法解析的外部符号 _netstackdump_read
的错误
在 rtmp.c 中 查找 netstackdump 后
注释掉 下面的代码
//#ifdef _DEBUG
//extern FILE *netstackdump;
//extern FILE *netstackdump_read;
//#endif
//#ifdef _DEBUG
// fwrite(ptr, 1, nBytes, netstackdump_read);
//#endif
//#ifdef _DEBUG
// fwrite(buf, 1, len, netstackdump);
//#endif
重新编译 librtmp 即可