Receiving ostream linker errors from VC6 built library

P

Paul Brun

I have a library that is built in VC6 which contains references to the new
iostream instead
of "iostream.h" to accomodate my .NET Studio built C++ application. However,
in debug mode, I
obtain the following linker warnings. The object files referenced are part
of the VC6 built libraries:

MiLibd.lib(MiInternetAddress.obj) : error LNK2019: unresolved external
symbol "__declspec(dllimport) class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl std::blush:perator<<(class
std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"
(__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
referenced in function "public: __thiscall
MiInternetAddress::MiInternetAddress(unsigned short)"
(??0MiInternetAddress@@QAE@G@Z)

MiLibd.lib(MiSocketInitializer.obj) : error LNK2001: unresolved external
symbol "__declspec(dllimport) class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl std::blush:perator<<(class
std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"
(__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)


Any ideas on what can cause the LINK2019 warnings for the basic_ostream
package after building
my VS.Net built c++ application. Are there signature differences that can
cause issues?

Would appreciate any form of an idea!!!

Thanks
Paul
 
T

Tom Widmer

Paul said:
I have a library that is built in VC6 which contains references to the new
iostream instead
of "iostream.h" to accomodate my .NET Studio built C++ application. However,
in debug mode, I
obtain the following linker warnings. The object files referenced are part
of the VC6 built libraries:

MiLibd.lib(MiInternetAddress.obj) : error LNK2019: unresolved external
symbol "__declspec(dllimport) class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl std::blush:perator<<(class
std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"
(__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)
referenced in function "public: __thiscall
MiInternetAddress::MiInternetAddress(unsigned short)"
(??0MiInternetAddress@@QAE@G@Z)

MiLibd.lib(MiSocketInitializer.obj) : error LNK2001: unresolved external
symbol "__declspec(dllimport) class std::basic_ostream<char,struct
std::char_traits<char> > & __cdecl std::blush:perator<<(class
std::basic_ostream<char,struct std::char_traits<char> > &,char const *)"
(__imp_??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z)


Any ideas on what can cause the LINK2019 warnings for the basic_ostream
package after building
my VS.Net built c++ application. Are there signature differences that can
cause issues?

Yes. The VC7.1 version of the library is different from the VC6 one -
the two can't be mixed at all.

The easiest fix is to recompile your VC6 library under VC.NET. Failing
that, you'll have to write a wrapper library in VC6 that exposes a C or
COM interface, since neither of these interface types suffers from
versioning problems.

The moral is: don't use C++ classes (and particularly standard library
ones) in the interface of DLLs or binary libraries, since Microsoft's
C++ ABI is not stable between versions, particularly the standard
library ABI. If you want to use C++ in a library, make sure you supply
(possible obfuscated) source code so that it can be recompiled if necessary.

Tom
 

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