Click to See Complete Forum and Search --> : Linker error when C++ 6.0 code using STL is ported to Visual Studio 2005


visharad
December 8th, 2006, 06:37 AM
Hi,
I wrote some code in C++ using Visual Studio 6.0. In that I used STL string by including <string>. It worked fine. Then I opened the same code in Visual Studio 2005 because I want to convert it into Visual C++.Net 2005.

I get the following error. Let me know what things I should change if a C++ code using STL is to be ported to C++.Net 2005. How to get rid of the following error? I am using string and map of STL? Do I need to make some changs for map also? Thanks.

I
Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator<(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (__imp_??Mstd@@YA_NABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@0@Z) referenced in function "public: bool __thiscall std::less<class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > >::operator()(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)const " (??R?$less@V?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@std@@QBE_NABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@0@Z)

Paul McKenzie
December 8th, 2006, 02:05 PM
Hi,
I wrote some code in C++ using Visual Studio 6.0. In that I used STL string by including <string>. It worked fine. Then I opened the same code in Visual Studio 2005 because I want to convert it into Visual C++.Net 2005.Is this managed code or regular C++? If this is normal C++ code, you shouldn't post your message in this forum.

Second, I have no problems "porting" string and map. They work right out of the box between VC 6.0 and Visual Studio 2005. The only thing that won't work is if you were writing illegal C++ code that VC 6.0 accepts, and now VC++ 2005 rejects (assuming iterators are pointers is the one bug that 2005 does not accept, while 6.0 accepted it).

Third, how about showing your code?

Regards,

Paul McKenzie