使用cppunit,编译成功而连接失败
这个问题在
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) 中导入