Linkage Issue in VC7 (2003) with VC6 Libraries

J

jim.massengale

The Libraries that I am linking with are compiled in Visual 6.0. I have
an exported CEPAttribute with the function
CEPAttribute::GetLineStyle(CString &_strValue). The project that I am
compiling in VC7 (2003) uses the CEPAttribute but doesn't call the
::GetLineStyle(CString) function.

When it links I get the following error:

error LNK2001: unresolved external symbol "public: virtual int
__thiscall CEPAttribute::GetLineStyle(class ATL::CStringT<char,class
StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &)const "
(?GetLineStyle@CEPAttribute@@UBEHAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)

Any ideas what the work around would be?
Jim
 
T

Tamas Demjen

When it links I get the following error:

error LNK2001: unresolved external symbol "public: virtual int
__thiscall CEPAttribute::GetLineStyle(class ATL::CStringT<char,class
StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &)const "
(?GetLineStyle@CEPAttribute@@UBEHAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)

Typically C++ compiled modules are not binary compatible among different
compilers. There's nothing you can do about that, your compilers are not
compatible. If you plan to export C++ classes, you must ensure that all
DLLs and the EXE are compiled with the exact same version of the
compiler, using the same compiler settings.
Any ideas what the work around would be?

1. Use the same compiler for all modules, and the dynamic version of the
RTL.
or
2. Export extern "C" functions with no C++ features in their argument list.
or
3. Make a very thin interface (abstract) class that's linked to both the
DLL and the EXE. Put the implementation (inheriting from the interface)
to the DLL, but only export 2 pure C functions that create and delete
your objects. Use virtual function calls to bind the interface to the
implementation. If done carefully, this can work across different
compilers. You must remember that the DLL and the EXE have their own
copy of C RTL (included their separate memory managers).
or
4. Use ActiveX/COM, which provides a portable (cross-compiler and
cross-language) interfacing solution.

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