views:

456

answers:

1

Hi all,

Today I met an link problem after updating the VS version from 2008 to 2010, the error is something like this:

error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) referenced in function "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z)

error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen@_String_base@std@@SAXXZ) referenced in function "protected: bool __thiscall std::basic_string,class std::allocator >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAE_NI_N@Z)

I have googled this issue on the web, and found a similar post in this address : http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/5ac28a31-3339-4db1-90f4-68edad360309

But none of these answers can solve my problem. Could anyone give me some tips on how to solve this issue?

Thanks a lot for the help!

+1  A: 

The problem is most likely that one of the libraries your .exe is linking against was built with a previous version of Visual Studio. Because this "other" library was compiled with a previous version of VS, it is looking for the previous versions of the functions _XRan and _XLen in the VS2010 C runtime. MS has changed them (yet again) and they old function signatures don't exist in the VS2010 runtime.

old: public: static void __cdecl std::_String_base::_Xran(void)

new: public: void __thiscall std::basic_string::_Xran(void) (this might be wrong, but you get the idea)

There are three possible fixes:

1) Compile all libraries with VS 2010

2) Use the older version of VS to compile your code

3) Rewrite the existing _XRan and _XLen implemenations and override in linker (see JN123's explanation in http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/5ac28a31-3339-4db1-90f4-68edad360309).

Jess