Link to home
Start Free TrialLog in
Avatar of fortineric
fortineric

asked on

STL DLL (std::wstring)

Problem: I have my CText class and CWordProperties Class, std::vector < CWordProperties> for my vector, and my vector is include in my CText Class, I try to export CText class with his vector outside the DLL.

This is my function who is export:
const CText __stdcall Parse (const std::wstring & wstrText, const in iLanguage);

I use std::wstring and std::string in my CWordProperties class. I overloade the operator < and ==.
This is what I got from the compiler.

Deleting intermediate files and output files for project 'ParseDLL - Win32 Debug'.
--------------------Configuration: ParseDLL - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\parsedll\wordproperties.h(126) : warning C4251: 'm_strWord' : class 'std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >' needs to have dll-interface to be used by clients of class 'CWor
dProperties'
c:\parsedll\wordproperties.h(128) : warning C4251: 'm_strTag' : class 'std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' needs to have dll-interface to be used by clients of class 'CWordProperties'
c:\parsedll\text.h(148) : warning C4251: 'm_strId' : class 'std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >' needs to have dll-interface to be used by clients of class 'CText'
c:\program files\microsoft visual studio\vc98\include\xutility(50) : error C2678: binary '<' : no operator defined which takes a left-hand operand of type 'const class CWordProperties' (or there is no acceptable conversion)
        c:\program files\microsoft visual studio\vc98\include\vector(218) : see reference to function template instantiation 'bool __stdcall std::lexicographical_compare(const class CWordProperties *,const class CWordProperties *,const class CWordPr
operties *,const class CWordProperties *)' being compiled
c:\program files\microsoft visual studio\vc98\include\xutility(52) : error C2678: binary '<' : no operator defined which takes a left-hand operand of type 'const class CWordProperties' (or there is no acceptable conversion)
        c:\program files\microsoft visual studio\vc98\include\vector(218) : see reference to function template instantiation 'bool __stdcall std::lexicographical_compare(const class CWordProperties *,const class CWordProperties *,const class CWordPr
operties *,const class CWordProperties *)' being compiled
Error executing cl.exe.

ParseDLL.dll - 2 error(s), 3 warning(s)
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GUNDAFLORIDA
GUNDAFLORIDA

listen....
The answers to your problem so far are already posted in your previous question ("DLL STL vector")
For the warnings in lines 126 and 128 of wordproperties.h: you should link to the DLL version of the runtime library. It already exports string and wstring.

The same for warning in line 148 of text.h.

For errors in xutility, make sure you have defined CWordProperties::operator < and CWordProperties operator ==


Actually the other question was different and had a very different answer.  The other question asked

"How can I pass by parameter a vector from DLL to exe file?"

which is almost trivial.  You just need to make sure you use a shared DLL RTL.  

This answer is about errors that occur becainse a class experted from a DLL contains and STL data member which does not have the DLL interface.
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "nietod" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Per recommendation comment force/accepted by

Netminder
Community Support Moderator
Experts Exchange