Man-Nag

I am building a project under 2005 (basically porting from VC 6.0). The Release version builds fine and the debug Version has some unresolved externals. I did include some of the libraries but could not make it work. Here is the error Message. I would appreciate any suggestions.

: error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >:Tongue Tiedwap(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (__imp_ swap@ $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAEXAAV12@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl StrPrintf(char const *,...)" ( StrPrintf@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@PBDZZ)

: error LNK2019: unresolved external symbol "__declspec(dllimport) 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> >(struct std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Has_debug_it)" (__imp_ 0 $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAE@U_Has_debug_it@01@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl StrPrintf(char const *,...)" ( StrPrintf@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@PBDZZ)

: error LNK2019: unresolved external symbol "__declspec(dllimport) 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> >:Surpriseperator+=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_ Y $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAEAAV01@ABV01@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Quote(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( Quote@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@ABV12@@Z)

: error LNK2019: unresolved external symbol "__declspec(dllimport) 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> >:Surpriseperator+=(char)" (__imp_ Y $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAEAAV01@D@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Quote(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( Quote@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@ABV12@@Z)

: error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::reserve(unsigned int)" (__imp_ reserve@ $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAEXI@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Quote(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( Quote@@YA AV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@ABV12@@Z)

error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::_Container_base::_Swap_all(class std::_Container_base &)const " (__imp_ _Swap_all@_Container_base@std@@QBEXAAV12@@Z) referenced in function "public: void __thiscall std::vector<char,class std::allocator<char> >:Tongue Tiedwap(class std::vector<char,class std::allocator<char> > &)" ( swap@ $vector@DV $allocator@D@std@@@std@@QAEXAAV12@@Z)

Thanks

Nag



Re: Visual C++ Language Unresolved External Symbol - Linker Error LNK2019

Man-Nag

Any thoughts on this





Re: Visual C++ Language Unresolved External Symbol - Linker Error LNK2019

Holger Grund

Make sure you don't link with /NODEFAULTLIB and that all contributing object files -- including those in static libraries -- are produced with the same compiler toolchain with compatible runtime library settings.

It would also help to give us the full diagnostics (e.g. are the errors in an object file contained in a static library )

Do you expect the references in this object file It looks like this is built with /MD and VC 8.

Do you link against msvcrtDrinks.lib That should work autmatically unless you use some obscure switches as /Zl or /NODEFAULTLIB.

Linking with /VERBOSE will tell you which libraries are selected and why. Watch out for msvcrt.

-hg





Re: Visual C++ Language Unresolved External Symbol - Linker Error LNK2019

Man-Nag

Hg:

I did try linking with msvcrtd.lib but sill the same problem.

In linker->input, here are the options set

Additional Dependencies : msvcrt.lib

Ignore all Default Libraries : NO

Ignore Specific Libraray : libcmtd.lib, msvcprtd.lib

Whether i include msvcrtd.lib or not, it doesnt make any difference and still gives errors for stl Libraries.

Thanks

Nag





Re: Visual C++ Language Unresolved External Symbol - Linker Error LNK2019

Holger Grund

Unless you really know what you're doing you shouldn't have anything in the above three settings.

The compiler automatically emits dependencies on the libraries it needs. If you then get a linker error about mismatched runtime libraries you should fix the compilation settings for these. /NODEFAULTLIB (BTW: Ignore all Default Libraries is a /NODEFAULTLIB without an argument, Ignore Specific Library translates to /NODEFAULTLIB:<library-to-ignore>) just masks some problems.

Can you rebuild all source files and all static libraries under VC8 with /MDd

mscvrtDrinks is the DLL version of the C Runtime

msvcptrDrinks is the DLL version of the C++ Runtime (this includes some preinstantiated templates such as std:Tongue Tiedtring)

libcmtDrinks and libcpmtDrinks are the static runtimes correspondingly.

-hg





Re: Visual C++ Language Unresolved External Symbol - Linker Error LNK2019

Man-Nag

Hg:

I do agree with you completely that compiler automatically emits the dependencies but in my case, linker was telling that there was conflict of multiple definitions and thats the reason, i had told the linker to ignore specific libraries.

I will rebuild all the libraries and will let u know.

Thanks

Nag