研究了很多文章,自己终于搞定了,总结一下。
JRTPLIB库是一个RTP协议的开源库,使用这套库文件,我们可以创建端到端的RTP连 接,实现数据的实时传输。
RTP是 实时传输协议的简称。压缩包可以从这里获得:
http://www.bairuitech.com/upimg/soft/jrtplib-3.7.1.rar
或者http://research.edm.uhasselt.be/~jori/page/index.php?n=CS.Jrtplib。
下载jrtplib-3.7.1.rar后,首先将其解压到一个临时文件夹中,然后开始后续工作。
首先需要强调的是,jrtplib是一个库而不是应用程序,编 译后我们获得的是.lib文件。这个文件是用来实现RTP协议的,意义和我们在写WIN32程序时用到的kernel.lib一样。
1、解 压后的文件夹中包含两个目录,jrtplib-3.7.1和jthread-1.2.1,打开这两个目录后我们可以看到下面又有两个同名的目录,为了后面能顺利编译,我们把同名目录下的 文件全部考到上一级目录中,就是说把c:\jrtplib-3.7.1\jrtplib-3.7.1\*.* 复制到c:\jrtplib-3.7.1\。同理,把c:\jthread-1.2.1\jthread-1.2.1\*.* 复制到c:\jthread-1.2.1\。完成上述步骤后我们就可以开始编译库文件了。
2、编 译jrtplib.lib和jthread.lib需要注意VC6要求安装Vs6sp6,在编译jrtplib.lib和jthread.lib前,在project——settings——C/C++——Code generation:use run-time library中,对于debug,选择:Debug Multithreaded DLL,对于release,则选择:Multithreaded DLL。
3、首 先编译jthread库,然后将jthread-1.2.1\src内的"jmutex.h"和"jthread.h"两个头文件放入jrtplib-3.7.1\src目录下,然后 将jrtplib-3.7.1\src文件夹下所有头文件中的<jmutex.h>和<jthread.h>语句修改为"jmutex.h"和"jthread.h",需要修改的文件为rtpudpv4transmitter.h、rtpsession.h和rtppollthread.h。编译时注意编译方式和jthread.lib一致,并且 设置路径包含jtrplib所有头文件,路径设置方法:工具--选 项--目录--include files.
4、将 编译生成的jthread.lib和jrtplib.lib拷贝到系统目录:C:\Program Files\Microsoft Visual Studio\VC98\Lib下。
5、那 些example的编译,需要在cpp文件开头加上:
#pragma comment(lib, "jrtplib.lib")
#pragma comment(lib, "jthread.lib")
#pragma comment(lib, "WS2_32.lib")//pragma的作用自己上网查吧
编译的时候,同样选择编译选项:Debug Multithreaded DLL(对于debug);Multithreaded DLL(对于release)。
然后编译-链接-运行就可以了。我在链接时还出了个错,参考http://leezen.blogbus.com/logs/22052169.html。
选择:Debug Multithreaded DLL,对于release,则选择:Multithreaded DLL。
这个很重要,不然编译时候会出现库冲突的错误
就像这样
Linking...
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in example1.obj
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *,class std::a
llocator<char> const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z) already defined in example1.obj
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Q
BEPBDXZ) already defined in example1.obj
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::ios_base::Init::Init(void)" (??0Init@ios_base@std@@QAE@XZ) already defined in libcpd.lib(iostream.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::ios_base::Init::~Init(void)" (??1Init@ios_base@std@@QAE@XZ) already defined in libcpd.lib(iostream.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::_Winit::_Winit(void)" (??0_Winit@std@@QAE@XZ) already defined in libcpd.lib(wiostrea.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::_Winit::~_Winit(void)" (??1_Winit@std@@QAE@XZ) already defined in libcpd.lib(wiostrea.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<c
har,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libcpd.lib(ios.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits
<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in example1.obj
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??6std@@YAAAV?$basic_ostream@DU?$cha
r_traits@D@std@@@0@AAV10@PBD@Z) already defined in example1.obj
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@
@1@AAV21@@Z) already defined in example1.obj
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: __snprintf already defined in LIBCD.lib(snprintf.obj)
MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
LINK : warning LNK4098: defaultlib "MSVCRTD" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/example1.exe : fatal error LNK1169: one or more multiply defined symbols found
转自http://wangjiajun53880.blog.163.com/blog/static/11700139420106188057684/