大家好,
最近我转换了一个项目从EVC4到VS2005,在EVC中编译也链接都没问题,但在VS2005,却出现了下面的link error:
研究了很长时间,都没有解决,希望大家能给点帮助。
tils.obj : warning LNK4049: locally defined symbol ?_C@?1??_Nullstr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@CAPBDXZ@4DB (char const `private: static char const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C) imported
mfcs80ud.lib(stdafx.obj) : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
FavoriteManager.obj : error LNK2019: unresolved external symbol __imp__CrtDbgReportW referenced in function "public: char * __cdecl ATL::CTempBuffer::AllocateBytes(unsigned int)" (?AllocateBytes@?$CTempBuffer@D$0IA@VCCRTAllocator@ATL@@@ATL@@QAAPADI@Z)
PersistencyInterface.obj : error LNK2001: unresolved external symbol __imp__CrtDbgReportW
ResString.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@XZ)
RouteInfo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
POICategoriesList.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::_Lockit::~_Lockit(void)" (__imp_??1_Lockit@std@@QAA@XZ)
NavConfirmInfoDlg.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl std::_Lockit::~_Lockit(void)" (__imp_??1_Lockit@std@@QAA@XZ) referenced in function __unwind$109524
NavMapGuidanceDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::_Lockit::~_Lockit(void)" (__imp_??1_Lockit@std@@QAA@XZ)
POIElementFilter.obj : error LNK2019: unresolved external symbol "public: struct MULTIFIRSTLETTER __cdecl CHanziToPinyin::GetFirstLetter(wchar_t)" (?GetFirstLetter@CHanziToPinyin@@QAA?AUMULTIFIRSTLETTER@@_W@Z) referenced in function "protected: virtual bool __cdecl CPOIElementFilter::filter(class NSVD::CPoiData const &)" (?filter@CPOIElementFilter@@MAA_NABVCPoiData@NSVD@@@Z)
atlsd.lib(atltypes.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(atlbase.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(Allocate.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(AtlDebugAPI.obj) : error LNK2019: unresolved external symbol _CrtDbgReportW referenced in function AtlTraceRegister
atlsd.lib(Externs.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(atltrace.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
atlsd.lib(atltime.obj) : error LNK2001: unresolved external symbol _CrtDbgReportW
this kind error, just need change the C/C++->code generation-> runtime library "Multi-threaded Debug (/MTd)" ->Multi-threaded Debug DLL (/MDd)
不行,还是有错
Utils.obj : warning LNK4049: locally defined symbol ?_C@?1??_Nullstr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@CAPBDXZ@4DB (char const `private: static char const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C) imported
Utils.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@XZ)
RouteListDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@XZ)
NavConfirmInfoDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl
Formatter.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl Utils.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::basic_string,class std::allocator >(wchar_t const *,class std::allocator const &)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@PB_WABV?$allocator@_W@1@@Z) referenced in function __unwind$93035
NavConfirmInfoDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::basic_string,class std::allocator >(wchar_t const *,class std::allocator const &)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@PB_WABV?$allocator@_W@1@@Z)
RouteListDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::basic_string,class std::allocator >::basic_string,class std::allocator >(wchar_t const *,class std::allocator const &)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAA@PB_WABV?$allocator@_W@1@@Z)
Formatter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: wchar_t * __cdecl std::basic_string,class std::allocator >::begin(void)" (__imp_?begin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAAPA_WXZ) referenced in function __unwind$104235
Formatter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: wchar_t * __cdecl std::basic_string,class std::allocator >::end(void)" (__imp_?end@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAAPA_WXZ) referenced in function __unwind$104235
RouteListDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
POIElementFilter.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
Formatter.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
POIDetailsDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
POIListDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
RouteInfo.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) wchar_t const `private: static wchar_t const * __cdecl std::basic_string,class std::allocator >::_Nullstr(void)'::`2'::_C" (__imp_?_C@?1??_Nullstr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@CAPB_WXZ@4_WB)
POIElementFilter.obj : error LNK2019: unresolved external symbol "public: struct MULTIFIRSTLETTER __cdecl CHanziToPinyin::GetFirstLetter(wchar_t)" (?GetFirstLetter@CHanziToPinyin@@QAA?AUMULTIFIRSTLETTER@@_W@Z) referenced in function "protected: virtual bool __cdecl CPOIElementFilter::filter(class NSVD::CPoiData const &)" (?filter@CPOIElementFilter@@MAA_NABVCPoiData@NSVD@@@Z)
应该还是在设置上有问题。
我以前遇到这种情况就改
C/C++-> code generation-> runtime library "Multi-threaded Debug (/MTd)" -> Multi-threaded Debug DLL (/MDd)
再不行就新建一个vs2005的工程,然后把文件从原来的工程复制过来,实现升级的。
在我的项目中,有这样一个Util.cpp文件,其中有下面一个方法,
std::wstring CUtils::ToWString(const std::string& s)
{
std::wstring res;
Utf8ToWide(s, res);
return res;
}
我发现,如果我调用这个方法,它就会出现上面的链接错误,否则就不会出现。
我也不知道为什么?
你把Utf8ToWide这个函数改写了吧,
函数意思就是把std::string 转成std::wstring吧
不是,我是想把单字节转换有宽字节,
其实我认为是std::wstring的错,因为
如果我声明一个warning C4231: nonstandard extension used : 'extern' before template explicit instantiation temp这样的变量,它也会出现同样的link error.