一个Link2001错误问题:unresolved external symbol "__declspec(dllimport)...

lcx517 2007-01-05 12:12:50
我新建了一个Win32 Dynamic-Link Library项目,并添加好最基本的框架代码(test.cpp)。一切都没问题。
我需要在项目中引用到jrtplib库的文件。操作如下:
在project|Settings|Link中添加了jthread.lib jrtplib.lib(两个必须的库);
新建了一个类CRtp专门操作jrtplib相关功能;
在CRtp中添加了最基本的框架代码; (如果是exe项目,完全没有问题的)
然后在test.cpp中include rtp.h……

rtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (__imp_?c_
str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::length(void)const " (__imp_?l
ength@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static unsigned int const std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::npos" (__imp_?npos@?$basic_
string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2IB)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find(char,unsigned int)const
" (__imp_?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIDI@Z)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) 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)" (__imp_??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator==(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_st
ring<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??8std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) 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::allocator<char> const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::Init(void)" (__imp_??0Init@ios_base@std@@QAE@XZ)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::Init(void)" (__imp_??0Init@ios_base@std@@QAE@XZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::~Init(void)" (__imp_??1Init@ios_base@std@@QAE@XZ)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::ios_base::Init::~Init(void)" (__imp_??1Init@ios_base@std@@QAE@XZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::_Winit(void)" (__imp_??0_Winit@std@@QAE@XZ)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::_Winit(void)" (__imp_??0_Winit@std@@QAE@XZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::~_Winit(void)" (__imp_??1_Winit@std@@QAE@XZ)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Winit::~_Winit(void)" (__imp_??1_Winit@std@@QAE@XZ)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator<(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_str
ing<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??Mstd@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z)
jrtplibd.lib(rtpudpv4transmitter.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) 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<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) 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> > &))" (__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) 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 *)" (__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > std::cerr" (__imp_?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A)
jrtplibd.lib(rtppollthread.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (_
_imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z)
Debug/testlib.ax : fatal error LNK1120: 17 unresolved externals

请问这该怎么解决啊?谢谢
--------------------
其他线索参考:
因为这个Dll开发需要,在Project|Settings|C/C++|Calling convention选择__stdcall. Settings|Link中选择了Ignore all default libraries.如果不选这个出现另一种link错误:
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)...
...全文
8693 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ls443085074 2012-05-14
  • 打赏
  • 举报
回复
看看,这个库的头文件是否include了,还有看看你的lib放到附加库目录指向的位置了没有,有可能是lib没找到的原因
牛 魔 王 2012-05-12
  • 打赏
  • 举报
回复
库文件
柚子毛驴 2011-06-01
  • 打赏
  • 举报
回复
就是缺少引用库所致。
楼主可以检查一下自己所引用的库和头文件。
lyn_hap 2011-05-31
  • 打赏
  • 举报
回复
我遇到这个问题的时候是因为外部友元函数设为inline的原因。去掉inline就好了。不知道楼主什么原因。可以试一下。
m_2010_m 2010-11-12
  • 打赏
  • 举报
回复
各位,我遇到一个差不多的问题:error LNK2001: unresolved external symbol "__declspec(dllimport) public: class _com_ptr_t<class _com_IIID<struct _Connection,&struct __s_GUID _GUID_00001550_0000_0010_8000_00aa006d2ea4> > __thiscall CADOConnection::GetConnection(void)求救啊!!!!
王国凡 2007-01-05
  • 打赏
  • 举报
回复
先恢复对 Ignore all default libraries 选项的修改.
可能是缺少头文件所致, 看起来象是需要包含 string.h
lcx517 2007-01-05
  • 打赏
  • 举报
回复
Ignore all default libraries 去掉就像上边说的那种LNK2005错误一样。
错误应该是跟库文件有关,而不是include .h文件吧……因为我在.exe项目中应用jrtplib完全正常,没有涉及__declspec(dllimport)之类的东东

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧