[xsd-users] Issue with VS2017

Boris Kolpackov boris at codesynthesis.com
Fri Mar 29 10:32:44 EDT 2019


rjl at third-monday.com <rjl at third-monday.com> writes:

> I'm using XSD 3.3.0 and Xerces 3.1 on Windows.
> 
> [...]
> 
> I'm migrating to VS2017 [...]

As a first step, I would suggest that you upgrade to at least XSD 4.0.0,
or even to the next version pre-release:

https://codesynthesis.com/~boris/tmp/xsd/4.1.0.a11/


> I'm getting some rather strange LNK2005 errors on std::string methods
> and operators.

In a nutshell, the reason for these errors is:

1. XSD implements certain basic types by deriving from std::string
   (because they have the 'is-a' relationship to xsd:string in XML
   Schema).

2. MSVC automatically applies the dllimport/dllexport of a derived
   class to a base class that doesn't have its own (and which
   std::string doesn't).

3. In MSVC 2017 (but not 2008) the implementation of std::string
   now contains non-inline member functions (or inline ones that
   the compiler chooses not to inline in Debug).

4. If you have two or more DLLs that include the generated code,
   then you may end up with duplicate std::string symbols because
   they both export them (see 2 above).

There are various ways to solve this problem with the easiest
being to place all the generated code into a single DLL. For
other ways see this earlier post:

http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003011.html

With this email containing more analysis/information on the problem:

http://www.codesynthesis.com/pipermail/xsd-users/2010-September/003019.html



More information about the xsd-users mailing list