[xsd-users] Issue with using xsd generated code in DLLs with Visual Studio 2010

Timo Geusch timo.geusch at styleadvisor.com
Mon Sep 20 15:48:23 EDT 2010


Hi Boris,

> -----Original Message-----
> From: Boris Kolpackov [mailto:boris at codesynthesis.com]
> Sent: Friday, September 17, 2010 6:41 AM
> To: Timo Geusch
> Cc: xsd-users at codesynthesis.com; Thomas Witt
> Subject: Re: [xsd-users] Issue with using xsd generated code in DLLs
> with Visual Studio 2010
> 
> Hi Timo,
> 
> Timo Geusch <timo.geusch at styleadvisor.com> writes:
> 
> > It looks like Microsoft did change the implementation of their
> standard
> > library in VS2010 however, and as a side effect it appears that
> classes
> > which derive from standard C++ classes like std::basic_string etc
> trigger
> > an export of their base class's symbols. In other words, the class
> > xsd::cxx::string as defined in cxx/tree/types.hxx results in the DLL
> > exporting most of std::basic_string. Try to link two DLLs that both
> > use and export a generated schema and the build will fail with the
> > linker complaining about duplicate symbols.
> 
> I think this can be resolved by exporting the types in the XML Schema
> namespace. Here is how this can be done:

[snip]

> Let me know if this works for you.

I've just tried this with a subset of the DLLs in the project. Unfortunately the suggested workaround still results in the same problem - the "root" DLL still exports symbols that are part of the std namespace - say, std::basic_string<char>::front() that subsequently clashes with the same symbol in one of the 'leaf' DLLs because in the default build settings, the affected C++ classes are header-only.

>From reading up on this issue on the various threads on the Microsoft site, it appears that the suggested workaround - well, the only one I have found so far - is to replace inheritance with composition. I'm not sure that this is the only way so I'll keep searching for an alternative, but for the time being I'm very open to other good ideas in this space.

With best regards,
Timo



More information about the xsd-users mailing list