Unresolved Externals

10 09 2006

To try out some of the ideas Dave and I have had, I’ve been putting together some command-line tools with Visual C++.NET 2003 SP1 and the Platform SDK.

Although these tools built without error using the IDE-provided ‘Debug’ build configuration, when I initially tried building them with the ‘Release’ configuration, the linker spat out a ream of errors along the lines of:


Tag.obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)

TaggedFile.obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)

Tagger.obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)

Main.obj : error LNK2001: unresolved external symbol "class std::basic_ostream > std::wcout" (?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A)

Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall std::locale::facet::_Register(void)" (?_Register@facet@locale@std@@QAEXXZ) referenced in function "class std::ctype const & __cdecl std::use_facet >(class std::locale const &)" (??$use_facet@V?$ctype@_W@std@@@std@@YAABV?$ctype@_W@0@ABVlocale@0@@Z)

Main.obj : error LNK2019: unresolved external symbol "public: class std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned int)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I@Z) referenced in function "class std::ctype const & __cdecl std::use_facet >(class std::locale const &)" (??$use_facet@V?$ctype@_W@std@@@std@@YAABV?$ctype@_W@0@ABVlocale@0@@Z)

Main.obj : error LNK2001: unresolved external symbol "public: static class std::locale::id std::ctype::id" (?id@?$ctype@_W@std@@2V0locale@2@A)

Main.obj : error LNK2019: unresolved external symbol __Getwctype referenced in function "protected: virtual bool __thiscall std::ctype::do_is(short,wchar_t)const " (?do_is@?$ctype@_W@std@@MBE_NF_W@Z)

A user on the Valve Developer Community wiki recommends removing references to the Platform SDK from the IDE to resolve a not dissimilar problem.

I’ve found it sufficient to remove “libcp.lib” from “\Lib” under the folder/directory into which the Platform SDK is installed; seemingly, the Platform SDK ships with a version of libcp.lib which conflicts with headers and/or libraries included in some versions of Visual C++.

If you know of a better solution or workaround, please share it in the comments.