jRTP中example1的编译错误小集

推荐一个比较全的jRTPlib使用教程先。

JRTPLIB@Conference(点此跟教程作者联系)

Google或者百度一下上述关键词即可。

顺便附个链接 http://www.google.com.hk/search?q=JRTPLIB%40Conference&ie=UTF-8&oe=GB2312&hl=zh-CN&domains=www.cnitblog.com/tinnal&sitesearch=www.cnitblog.com/tinnal

 

我用的是VC++ 6.0

主要参考了以下博客

http://blog.csdn.net/markman101/archive/2010/04/27/5532270.aspx

 

提示:在使用jRTPLIB之前,需要先下载并编译jRTPlib和jthread。生成jrtplib.lib和jthread.lib文件后,才能使用jrtplib。

关于编译生成lib文件,可以参考以下博客

http://leezen.blogbus.com/logs/22052259.html

 

下面开始尝试example1的编译。

 

首先,新建一个空工程。将example1.cpp复制到工程的文件夹内。而后单击project->Add to project->File... 选中example1.cpp 将其加入工程。

 

此时,

第一次编译。出现1个错误。

fatal error C1083: Cannot open include file: 'rtpsession.h': No such file or directory

当然啦,我没把jrtplib里的头文件加进来,自然找不到。

solution:

在tools->options..对话框中的directories选项卡中的include files中添加两个文件夹。

.../JRTPLIB-3.7.1/SRC

.../JTHREAD-1.2.1/SRC

也就是找到JRTPLIB的src和JTHREAD的src。具体路径可能与本文所述不同。

 


 

第二次编译,22个错误。

example1.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl RTPGetErrorString(int)" (?RTPGetErrorString@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allo
cator@D@2@@std@@H@Z)
example1.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
example1.obj : error LNK2001: unresolved external symbol "public: void __thiscall RTPSession::BYEDestroy(class RTPTime const &,void const *,unsigned int)" (?BYEDestroy@RTPSession@@QAEXABVRTPTime@@PBXI@Z)

……


example1.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall RTPIPv4Address::IsSameAddress(class RTPAddress const *)const " (?IsSameAddress@RTPIPv4Address@@UBE_NPBVRTPAddress@@@Z)
example1.obj : error LNK2001: unresolved external symbol "public: virtual class RTPAddress * __thiscall RTPIPv4Address::CreateCopy(class RTPMemoryManager *)const " (?CreateCopy@RTPIPv4Address@@UBEPAVRTPAddress@@PAVRTPMemoryManager@@@Z)
Debug/rtp_test.exe : fatal error LNK1120: 21 unresolved externals
Error executing link.exe.

rtp_test.exe - 22 error(s), 5 warning(s)

头大了吧。这是因为没有加上jrtp的lib,因此出现许多无法解析的外部符号。

solution:

在文件开头预编译处加上

#pragma comment(lib, "jrtplib.lib")
#pragma comment(lib, "jthread.lib")
#pragma comment(lib, "ws2_32.lib")

即可。

若不想对文件进行修改,可Project -> setting -> Link 中把 jrtplib.lib jthread.lib ws2_32.lib 加进去,这样就不用修改文件啦。

PS:笔者只试过前者,后者为百度搜索中多个博客中提及此方法,笔者未作尝试。

 

第三次编译。出现309errors。

Linking...
jrtplib.lib(rtperrors.obj) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored
jrtplib.lib(rtperrors.obj) : warning LNK4044: unrecognized option "manifestdependency:type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"; ignored
jrtplib.lib(rtperrors.obj) : warning LNK4044: unrecognized option "alternatename:__imp_??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z=__imp_??Hstd@@YA?AV?$basic_string@DU?$
char_traits@D@std@@V?$allocator@D@2@@0@ABV10@0@Z"; ignored

 

……

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::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in example1.obj


……

 

jrtplib.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (__imp_?_Unlock@?$basic_streambuf@DU?$char_traits@D@s
td@@@std@@QAEXXZ)
jrtplib.lib(rtprandom.obj) : error LNK2001: unresolved external symbol __imp___time64
jrtplib.lib(rtprandom.obj) : error LNK2001: unresolved external symbol __imp__rand_s
Debug/rtp_test.exe : fatal error LNK1120: 33 unresolved externals
Error executing link.exe.

rtp_test.exe - 309 error(s), 54 warning(s)

主要错误是LNK2005和LNK2001。

查阅了博客

solution to msvcprtd.lib(MSVCP60D.dll) : error LNK2005这个错误:

Project -> setting -> C/C++ ,Category中选择Code Generation,然后在Userun-time library中选择Multithreaded DLL,因为我们用到了多线程的链接库,得修改这个地方

 

第四次编译,288errors。

LNK2005错误消失,仅剩LNK2001。

按笔者理解,在tools->options.. 对话框中的directories选项卡中的include files、library files以及source files中添加jrtplib涉及到的文件夹即可。但是如此尝试没有奏效。

solution to jrtplib.lib(rtprandom.obj) : error LNK2001:

于是,采用最初提到的主要参考博客中使用的方法

http://blog.csdn.net/markman101/archive/2010/04/27/5532270.aspx

将jrtplib/src文件夹中所有文件复制到此工程文件夹中,并添加至工程中 project->Add to project->File... 。

 

编译...

 

0 error...

终于成功。

可以运行啦。

 

终于成功。

 

 

另外附一个可能出现的错误

fatal error LNK1104: cannot open file "jrtplib.lib"

因为我在处理LNK2001时已经将所有相关文件夹加入library files,所以不会出现该错误。

solution:

tools->options.. 对话框中的directories选项卡中的library files中加入jrtplib.lib和jthread.lib所在文件夹即可。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值