"Ash Jings" <jinagarashwini@gmail.com> wrote in message
news:C1644551-773C-4C91-940E-553313F3A852@microsoft.com...
How to use CString object in non MFC programs ??
I have a slighlty more complicated problem:
I have a non-MFC DLL, N.DLL say, from which I export classes with methods
returning a CStringW.
And an MFC DLL, M.DLL say, which contains code which calls those methods.
class IMORTITEM is one such class in N.DLL
it has a method
CStringW IMPORTITEM::iiTextString() const;
class CMzImporter lives in M.DLL and attempts to call it.
Upon linking M.DLL I get error messages like:
1>import1.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: class ATL::CStringT<wchar_t,class
StrTraitMFC_DLL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > __thiscall
IMPORTITEM::iiTextString(void)const "
(__imp_?iiTextString@IMPORTITEM@@QBE?AV?$CStringT@_WV?$StrTraitMFC_DLL@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@XZ)
referenced in function "private: bool __thiscall
CMzImporter::imImportStartItems(class IMPORTDATA &)"
(?imImportStartItems@CMzImporter@@AAE_NAAVIMPORTDATA@@@Z)
It appears that the CStringW declared as the return value of the class
member in N.DLL (defined in atlstr.h) is not being recognised as the same as
the CStringW as defined in the MFC DLL header???? Or????
Any ideas what to do about it?
The IMPORTITEM class is exported by the standard mechanism:
#ifdef MZW32N_EXPORTS
#define MZWN_API __declspec(dllexport)
#else
#define MZWN_API __declspec(dllimport)
#endif
class MZWN_API IMPORTITEM ....
needs to link to the DLL form of MFC for this to work.