使用cppunit,编译成功而连接失败

sleepingboy 2004-04-17 03:03:42
这个问题在
http://search.csdn.net/expert/topic/56/5603/2003/10/17/2366654.xml
已有类似讨论

cppunit 1.9.14,编译器vc7.1,操作系统xp sp1

我建立一个win32控制台项目
添加1个用于测试的类
将cppunitd.lib添加到 链接器-〉输入-〉附加依赖项
忽略指定库 msvcrtd.lib
启用运行时类型信息(/GR)设置为 是

我还需要再做哪些设置?

链接器的命令行如下:
/OUT:"Debug/MyABC.exe" /INCREMENTAL /NOLOGO /NODEFAULTLIB:"msvcrtd.lib" /DEBUG /PDB:"Debug/MyABC.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 E:\cppunit-1.9.14\lib\cppunitd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

部分错误和警告信息如下:
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_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) 已经在 MyTest.obj 中定义

error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: char const * __thiscall type_info::name(void)const " (__imp_?name@type_info@@QBEPBDXZ) ,该符号在函数 "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CppUnit::TypeInfoHelper::getClassName(class type_info const &)" (?getClassName@TypeInfoHelper@CppUnit@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVtype_info@@@Z) 中被引用

error LNK2019: 无法解析的外部符号 __imp___assert ,该符号在函数 "public: static class CppUnit::TestFactoryRegistry * __cdecl CppUnit::TestFactoryRegistryList::getRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getRegistry@TestFactoryRegistryList@CppUnit@@SAPAVTestFactoryRegistry@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 中被引用

warning LNK4049: 已导入本地定义的符号 ??0bad_cast@@QAE@PBD@Z (public: __thiscall bad_cast::bad_cast(char const *))

warning LNK4217: 本地定义的符号 _memmove 在函数 "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * * __cdecl std::_Uninit_copy<class std::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> > *>(class std::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> > * *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * *,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *> &,struct std::_Scalar_ptr_iterator_tag)" (??$_Uninit_copy@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAV12@@std@@YAPAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PAPAV10@00AAV?$allocator@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@0@U_Scalar_ptr_iterator_tag@0@@Z) 中导入
...全文
182 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
angelboycn 2004-04-18
  • 打赏
  • 举报
回复
帮你顶下~看看别人怎么解答~
sleepingboy 2004-04-18
  • 打赏
  • 举报
回复
thx cgsw12345
你解决ace的帖子里让我记起cppunit的FAQ,那里面也提到
In Release configuration, CppUnit use "Mulithreaded DLL".
In Debug configurations, CppUnit use "Debug Multihreaded DLL".
把运行时也调整一下就没再报错了
sleepingboy 2004-04-18
  • 打赏
  • 举报
回复
我尝试将cppunit_dll.dll cppunitd_dll.dll testrunner.dll testrunnerd.dll
复制到/debug文件夹和项目所在的文件夹
错误和警告信息不变
cgsw12345 2004-04-18
  • 打赏
  • 举报
回复
我就是这样解决了ACE的连接的问题
http://expert.csdn.net/Expert/topic/2965/2965761.xml?temp=.7674066
参考看看吧!
cgsw12345 2004-04-17
  • 打赏
  • 举报
回复
把你编译生成的dll文件拷贝到测试项目的当前目录下试试看!
zhouqingyuan 2004-04-17
  • 打赏
  • 举报
回复
cppunit
什么东东?
wshcdr 2004-04-17
  • 打赏
  • 举报
回复
感兴趣

帮顶下

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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