Click to See Complete Forum and Search --> : Passing ostream object to an constructor of unmanaged class...


svkr2k
July 12th, 2005, 12:16 AM
Dear forum members,

I have an unmanaged dll written in C++ using Visual Studio 6.0. I need to use this dll in an VC++ .Net application. The unmanaged dll has a class called CUnmanaged. Its constructor accepts reference to ostream object:

CUnmanaged::CUnmanaged( ostream& os )
{
/* ... */
}

In the VC++.Net client application, the object of CUnmanaged is created as follows:

filebuf fb;
fb.open ("c:\\test1.txt",ios:: out);
ostream os(&fb);
os << "Test sentence\n";
CUnmanaged objUnmanmaged( os );
fb.close();

When linking, I get the following error:
error LNK2001: unresolved external symbol "public: __thiscall CUnmanaged::CUnmanaged(class std::basic_ostream<char,struct std::char_traits<char> > &)" (??CUnmanaged@@$$FQAE@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)

Can anyone suggest some solution for this ?
Thanks in advance.
-Rajesh.

Andreas Masur
July 12th, 2005, 12:32 AM
Make sure that you have added all needed files for the dll (header plus import library). Other than that....did you export the constructor from the dll?

svkr2k
July 12th, 2005, 12:37 AM
Hi Andreas Masur,

The class CUnmanaged is declared as:
class __declspec (dllexport) CUnmanaged
{
public:
CUnmanaged( ostream& os );

CUnmanaged( const std::string& filename );

/* more methods */

}

So, I hope the constructors are exported ?