Welcome to MSDN Blogs Sign in | Join | Help

Weird LNK 2019 on a VS 2005 ported dll

1>stdafx.obj : error LNK2019: unresolved external symbol "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) referenced in function "public: char * __cdecl std::_DebugHeapAllocator<char>::allocate(unsigned int,void const *)" (?allocate@?$_DebugHeapAllocator@D@std@@QAAPADIPBX@Z)

1>stdafx.obj : error LNK2019: unresolved external symbol "struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)" (?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) referenced in function "public: char * __cdecl std::_DebugHeapAllocator<char>::allocate(unsigned int,void const *)" (?allocate@?$_DebugHeapAllocator@D@std@@QAAPADIPBX@Z)

Recently during a project upgrade from Visual Studio.NET 2003 to VS.NET 2005 i came across the above link error. The app is a normal dll that used CRT to do its stuff. This error occurs only in debug mode. The release mode compiled without any issues.

The VS.NET 2003 original project is not mine so i didn't know a lot about the settings. I decided to check the configuration and settings that the app was being built with.

The issue turned out to be the inclusion of 'libcmt.lib' in the debug mode. The debug version of libcmt is 'libcmtd.lib'. I changed the settings to include libcmtd.lib and removed the '/NODEFAULTLIB' that was specified. Still there were error messages as if libcmt was also included. I then had to explicitly ignore 'libcmt'. Things built properly from then

A couple of interesting things about this -

1) libcmt is not included directly. It comes from a static lib that's referred by the dll. ( Added on Aug 10 : The above statement is incorrect. Thanks to hmm for pointing this out.I will update here once i find out the actual reason)

2) VS 2003 didn't complain.

Published Tuesday, August 08, 2006 9:52 AM by seshadripv

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Weird LNK 2019 on a VS 2005 ported dll

I don't understand. How would another static lib be able to pull in libcmt ? libs don't link against other libs, executables do.
Please clarify :)
Tuesday, August 08, 2006 10:36 AM by hmm

# re: Weird LNK 2019 on a VS 2005 ported dll

Hi

I am also getting the same problem. Can you give more explanation?.

The following is linker errors i am getting,

MN.obj : error LNK2019: unresolved external symbol "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) referenced in function "public: char * __cdecl std::_DebugHeapAllocator<char>::allocate(unsigned int,void const *)" (?allocate@?$_DebugHeapAllocator@D@std@@QAAPADIPBX@Z)

MN.obj : error LNK2019: unresolved external symbol "struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)" (?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) referenced in function "public: char * __cdecl std::_DebugHeapAllocator<char>::allocate(unsigned int,void const *)" (?allocate@?$_DebugHeapAllocator@D@std@@QAAPADIPBX@Z)

MN.obj : error LNK2019: unresolved external symbol "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) referenced in function "public: void __thiscall std::_Iterator_base::_Orphan_me(void)" (?_Orphan_me@_Iterator_base@std@@QAEXXZ)

MN.obj : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "public: bool __thiscall std::_Tree<class std::_Tmap_traits<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator::operator==(class std::_Tree<class std::_Tmap_traits<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,0> >::const_iterator const &)const " (??8const_iterator@?$_Tree@V?$_Tmap_traits@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@2@$0A@@std@@@std@@QBE_NABV012@@Z)

I set the following options

Ignore specific libary :libcmtd; libcpmtd;libc

Runtime library : Multi-threaded Debug (/MTd)

Addtional Dependicies : Prod1.lib Util.lib ws2_32.lib odbc32.lib odbccp32.lib

Where Prod1 is built with run time library as Multi-threaded Debug (/MT). It is third party library.

Util.lib is built with run time library as Multi-threaded Debug (/MT).

In Prod1lib, libcmt.lib is explicitly included.

Regards,

Mukilan

Tuesday, March 13, 2007 9:38 AM by Mukilan

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker