先看一下错误吧,之前在debug下编译时没有问题的,但在release下时有问题的:
: error LNK2019: unresolved external symbol _strlen referenced in function "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z)
obj : error LNK2001: unresolved external symbol _strlen bj : error LNK2001: unresolved external symbol _strlen : error LNK2001: unresolved external symbol _strlen : error LNK2019: unresolved external symbol _memcpy referenced in function "public: static char * __cdecl std::char_traits<char>::copy(char *,char const *,unsigned int)" (?copy@?$char_traits@D@std@@SAPADPADPBDI@Z) obj : error LNK2001: unresolved external symbol _memcpy bj : error LNK2001: unresolved external symbol _memcpy : error LNK2001: unresolved external symbol _memcpy : error LNK2019: unresolved external symbol _memmove referenced in function "public: static char * __cdecl std::char_traits<char>::move(char *,char const *,unsigned int)" (?move@?$char_traits@D@std@@SAPADPADPBDI@Z) obj : error LNK2001: unresolved external symbol _memmove bj : error LNK2001: unresolved external symbol _memmove : error LNK2001: unresolved external symbol _memmove : error LNK2019: unresolved external symbol _memset referenced in function _ShowDiskSpaceDlg : error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) referenced in function _SetBtnSkin obj : error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) referenced in function "void __cdecl OnInitalDlg(struct HWND__ *,int)" (?OnInitalDlg@@YAXPAUHWND__@@H@Z) bj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) : error LNK2019: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) referenced in function "public: void __thiscall std::allocator<char>::deallocate(char *,unsigned int)" (?deallocate@?$allocator@D@std@@QAEXPADI@Z) obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) bj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) : error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@ obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) bj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) : error LNK2019: unresolved external symbol ___CxxFrameHandler referenced in function __ehhandler$?_Copy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXII@Z obj : error LNK2001: unresolved external symbol ___CxxFrameHandler bj : error LNK2001: unresolved external symbol ___CxxFrameHandler : error LNK2001: unresolved external symbol ___CxxFrameHandler : error LNK2019: unresolved external symbol __except_list referenced in function $L63178 obj : error LNK2001: unresolved external symbol __except_list bj : error LNK2001: unresolved external symbol __except_list : error LNK2001: unresolved external symbol __except_list : error LNK2019: unresolved external symbol __EH_prolog referenced in function "protected: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int,unsigned int)" (?_Copy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXII@Z) obj : error LNK2001: unresolved external symbol __EH_prolog bj : error LNK2001: unresolved external symbol __EH_prolog : error LNK2001: unresolved external symbol __EH_prolog : error LNK2019: unresolved external symbol __CxxThrowException@8 referenced in function $L63178 obj : error LNK2001: unresolved external symbol __CxxThrowException@8 bj : error LNK2001: unresolved external symbol __CxxThrowException@8 : error LNK2001: unresolved external symbol __CxxThrowException@8 : error LNK2019: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) referenced in function "protected: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z) obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) bj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) : error LNK2019: unresolved external symbol "public: virtual __thiscall exception::~exception(void)" (??1exception@@UAE@XZ) referenced in function "public: virtual __thiscall std::logic_error::~logic_error(void)" (??1logic_error@std@@UAE@XZ) obj : error LNK2001: unresolved external symbol "public: virtual __thiscall exception::~exception(void)" (??1exception@@UAE@XZ) bj : error LNK2001: unresolved external symbol "public: virtual __thiscall exception::~exception(void)" (??1exception@@UAE@XZ) : error LNK2001: unresolved external symbol "public: virtual __thiscall exception::~exception(void)" (??1exception@@UAE@XZ) : error LNK2019: unresolved external symbol "public: __thiscall exception::exception(void)" (??0exception@@QAE@XZ) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)obj : error LNK2001: unresolved external symbol "public: __thiscall exception::exception(void)" (??0exception@@QAE@XZ)
是不是感觉头都大了,确实 我看到这也头大了,在Release下面Linker->Input->Ignore All default lib你选择了YES,问题是你不选YES也是一样。呵呵。出现这问题的主要原因是库没有连接对。上面是确实这个两个库MSVCRT.LIB MSVCPRT.LIB(我的环境是vs2003)。
这是MSND上相应的库,就按照这个表来,就没什么问题了
C Runtime Library:
开关
对应的库
版本
/MD
MSVCRT.LIB
多线程DLL的Release版本
/MDd
MSVCRTD.LIB
多线程DLL的Debug版本
/MT
LIBCMT.LIB
多线程静态链接的Release版本
/MTd
LIBCMTD.LIB
多线程静态链接的Debug版本
/clr
MSVCMRT.LIB
托管代码和非托管代码混合
/clr:pure
MSVCURT.LIB
纯托管代码
C++ Standard Library:
开关
对应的库
版本
/MD
MSVCPRT.LIB
多线程DLL的Release版本
/MDd
MSVCPRTD.LIB
多线程DLL的Debug版本
/MT
LIBCPMT.LIB
多线程静态链接的Release版本
/MTd
LIBCPMTD.LIB
多线程静态链接的Debug版本