[xsd-users] Linker problem caused by using std::ifstream/std::ofstream/std::fstream together with xsd::cxx::tree::string

Krzynowek, Marek (CWM-NR) marek.krzynowek at rbccm.com
Wed Sep 29 05:06:32 EDT 2021


Hi,

I'm in the process of updating the visual studio version for my team.
We're moving from Visual Studio 2019 16.6 to Visual Studio 2019 16.11 however we encountered a problem.

The issue is with linking:

LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned __int64,unsigned __int64)" (__imp_?erase@?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QEAAAEAV12 at _K0@Z) referenced in function "protected: virtual int __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::uflow(void)" (?uflow@?$basic_filebuf at DU?$char_traits at D@std@@@std@@MEAAHXZ)


It's caused by using std::ifstream/std::ofstream/std::fstream together with xsd::cxx::tree::string (which inherits from std::basic_string) from Codesynthesis XSD library in Visual Studio higher than 16.6, e.g. 16.11.3.

Minimal code to reproduce it (in a DLL project):


#include <fstream>

#include <xsd/cxx/tree/types.hxx>



typedef xsd::cxx::tree::type Type;

typedef xsd::cxx::tree::simple_type<char, Type> SimpleType;



template class __declspec(dllimport) xsd::cxx::tree::string<char, SimpleType>;



void f()

{

    std::ifstream fs;

}

Could you please have a look see if you can reproduce and suggest a way to fix this.

Thanks,
Marek Krzynowek

______________________________________________________________________ This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential. Unauthorised use or disclosure is prohibited. If you receive this e-mail in error, please advise immediately and delete the original message. This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message. Emails are monitored by supervisory personnel in jurisdictions where monitoring is permitted. Such communications are retained and may be produced to regulatory authorities or others with legal rights to the information. Please see link for RBCCM disclosures. https://www.rbccm.com/rbccm/policies-disclaimers.page


More information about the xsd-users mailing list