kenlistian

勤学多思

  IT博客 :: 首页 :: 新随笔 ::  :: 聚合  :: 管理 ::
  412 随笔 :: 0 文章 :: 23 评论 :: 0 Trackbacks

在vc6下编译jrtplib,但编译example1.cpp时产生了很多错误,有以下几种情况:

1) Use Run-time Library的设置一定要统一。
    2) VC产生的workspace的debug setting,默认有个GZ选项,
  Catch Release-Build Errors in Debug Build,编译的时候
  会说error LNK2001: unresolved external symbol __chkesp,
  去掉就好了。

3) 如果报有link2001其中有getusername错误,加入windows.h头文件,并且增加Advapi32.lib库

 

一、出现的问题之一

example2.obj : error LNK2019: 无法解析的外部符号
   "public: virtual __thiscall RTPSession::~RTPSession(void)" (??1RTPSession@@UAE@XZ) ,该符号在函数 _main 中被引用
example2.obj : error LNK2019: 无法解析的外部符号 __imp__WSACleanup@0 ,该符号在函数 _main 中被引用
example2.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall RTPSession::BYEDestroy(class RTPTime const &,void const *,unsigned int)" (?BYEDestroy@RTPSession@@QAEXABVRTPTime@@PBXI@Z) ,该符号在函数 _main 中被引用
example2.obj : error LNK2019: 无法解析的外部符号 "public: int __thiscall RTPSession::EndDataAccess(void)" (?EndDataAccess@RTPSession@@QAEHXZ) ,该符号在函数 _main 中被引用

很明显,是关于类RTPSession的问题,问题出在缺少lib库jrtplib.lib。

解决:加入

#pragma comment (lib, "jrtplib.lib")
    #pragma comment (lib, "jthread.lib")
  也可以在“链接器”中“附加依赖项”中添加这些库。

二、出现如下问题:
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 example2.obj 中定义
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) 已经在 example2.obj 中定义
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(class

解决方法:设置VC运行库(C/C++->CodeGeneration->Use Runtime library 选MultiThreaded DLL buildblog,再次提醒大家注意观察 buildblog里面的提示。
    因为运行时库的版本问题。VC编译器的运行时库有多个选项:/ML、/MLd、/MT、/MTd、/MD、/MDd。这些选项告诉编译器应用程序想使用什么版本的C标准程序库。这样会在运行时选择不同版本的库。
 

三、问题如下:
example2.obj : error LNK2019: 无法解析的外部符号__imp__WSACleanup@0 ,该符号在函数 _main 中被引用
example2.obj : error LNK2019: 无法解析的外部符号 __imp__WSAStartup@8 ,该符号在函数 _main 中被引用
jrtplib.lib(rtpsession.obj) : error LNK2019: 无法解析的外部符号 __imp__gethostname@8 ,该符号在函数 "private: int __thiscall RTPSession::CreateCNAME(unsigned char *,unsigned int *,bool)" (?CreateCNAME@RTPSession@@AAEHPAEPAI_N@Z) 中被引用
jrtplib.lib(rtpudpv4transmitter.obj) : ················

解决方法:#pragma comment (lib, "ws2_32.lib")

四,问题如下:

LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
jrtplib.lib(rtpsession.obj) : error LNK2001: unresolved external symbol __imp__GetUserNameA@8
LIBCMTD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/TestJRTP.exe : fatal error LNK1120: 2 unresolved externals

增加Advapi32.lib ,并加入windows.h即可.

(至于winmain错误,则重新在example中生成工程文件即可.至于那些库的头文件,通过option中的路径设置为缺省即可.)

总之在project中setting增加如下库jrtplib.lib jthread.lib ws2_32.lib Advapi32.lib

即可.

posted on 2009-04-28 16:27 kenlistian 阅读(2070) 评论(1)  编辑 收藏 引用

评论

# re: jrtplib的编译问题 2012-11-09 16:38 charles
确实解决了问题 谢谢分享!  回复  更多评论
  

只有注册用户登录后才能发表评论。