Re: LNK2001 error by nick
nick
Thu Apr 13 11:09:01 CDT 2006
I've used the inline function and so I moved the definition of the method to
head file. However, I have new Link error?
Error 1 error LNK2005: "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> >(char const *)"
(??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z)
already defined in common.lib(Common.obj) msvcprtd.lib
"Igor Tandetnik" wrote:
> "nick" <nick@discussions.microsoft.com> wrote in message
> news:9D226C27-7F30-4C0A-A63A-BEEA7287A8F3@microsoft.com
> > However, I always got the errors:
> >
> > Error 13 error LNK2001: unresolved external symbol "public: virtual
> > class
> > std::basic_string<char,struct std::char_traits<char>,class
> > std::allocator<char> > __thiscall Param<class CEmpty<double>
> > >::toStr(void)"
> > (?toStr@?$InParam@V?$CEmpty@N@@@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
> > proc.obj
>
> Have you by any chance implemented methods of a template class in a .cpp
> file? That's not going to work. The compiler needs to see the
> implementation at the point the template is used, so the code has to be
> in .h file.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>