Hi,
I have a C++ application that calls a function in another static library
which accepts a std::string parameter. However, my VS 2005 compiler shows
the following error:
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "class
std::basic_istream<char,struct std::char_traits<char> > & __cdecl
std::getline<char,struct std::char_traits<char>,class std::allocator<char>
>(class std::basic_istream<char,struct std::char_traits<char> > &,class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > &)"
(??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z) already defined in log4cppLIB.lib(Category.obj)
Any idea how I can resolve this problem?
Regards
cleohm
David Lowndes - 01 Feb 2007 12:13 GMT
>I have a C++ application that calls a function in another static library
>which accepts a std::string parameter. However, my VS 2005 compiler shows
>the following error:
>...
Ensure that both your application and the static library are build
with the same run-time library options. Since your EXE is trying to
use the DLL run-time, your static library should do exactly the same.
Also, ensure that a debug build of one uses the debug build of the
other, and vice-versa for the release build. Needless to say, all
should be built with the same version of the compiler/linker.
Dave
cleohm - 01 Feb 2007 13:10 GMT
Thanks for your reply. In fact I have recompiled my library in vs 2005 which
was previously in vs2003, and it works. However, something I am rather
curious about is that most open source libraries do not support vs2005
however, some of them recommend the use of a 2003 library and it works fine
in my vs2005. Is that a particular reason why?
> >I have a C++ application that calls a function in another static library
> >which accepts a std::string parameter. However, my VS 2005 compiler shows
[quoted text clipped - 9 lines]
>
> Dave
David Lowndes - 01 Feb 2007 15:01 GMT
>Thanks for your reply. In fact I have recompiled my library in vs 2005 which
>was previously in vs2003, and it works.
Great.
> However, something I am rather
>curious about is that most open source libraries do not support vs2005
>however, some of them recommend the use of a 2003 library and it works fine
>in my vs2005. Is that a particular reason why?
It's hard to say without a specific (concise) example. Generally
you're asking for problems if you try to use static libraries from
different versions of the compiler. If the library is for a DLL, then
providing the DLL interface does not involve types allocated from the
run-time (i.e. it uses POD types only, or ones from a common memory
manager), then it would be OK.
Dave
cleohm - 02 Feb 2007 13:06 GMT
Thanks!
> >Thanks for your reply. In fact I have recompiled my library in vs 2005 which
> >was previously in vs2003, and it works.
[quoted text clipped - 14 lines]
>
> Dave