error LNK2005: "class std::basic_istream

G

Guest

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 said:
(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
 
D

David Lowndes

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
 
G

Guest

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?
 
D

David Lowndes

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
 
G

Guest

Thanks!

David Lowndes said:
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
 

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