Confusing Managed C++ Link Errors?

T

Tommy Vercetti

I get the following odd link errors. This code builds perfectly in non
managed VC++ 7.1. Any ideas on where to begin?

thanks!

msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: class
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator said:
::erase(unsigned int,unsigned int)"
(?erase@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEAAV12@II@Z)
already defined in DomainDataMgr.obj
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: unsigned int
__thiscall std::basic_string<wchar_t,struct
std::char_traits said:
::size(void)const "
(?size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEIXZ)
already defined in DomainDataMgr.obj
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator<wchar_t> >::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >(class
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator<wchar_t> > const &)"
(??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV01@@Z)
already defined in DomainDataMgr.obj
msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: unsigned int
__thiscall std::basic_string<wchar_t,struct
std::char_traits said:
::max_size(void)const "
(?max_size@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEIXZ)
already defined in DomainDataMgr.obj
 
S

Sygnosys

Hello,

I had that same type of errors...I don't know if they are equal to your's,
so i will give you a brief explanation
and then let you decide if it's for you or not!! :))

I think the problem is that when we are using templates with managed
extensions the Managed Compiler will try to
complile it each template per include. Independently if that template
instantion already appears in the assembly.
For example
Souce1.cpp
#include <vector>
vector<char> x;

Source2.cpp
#include <vector>
vector<char> y;

This will generate the same type of errors you've got.....

I solved this problem by putting all teh template includes in the
precompiled header


100+
Cláudio Albuquerque
 
A

anthony

Try to create a MFC project from the VC7 wizard and check what header file
you are missing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top