[xsd-users] Issue with VS2017

rjl at third-monday.com rjl at third-monday.com
Thu Mar 28 12:17:19 EDT 2019


Bear with me here, this is a loooong email...

I'm using XSD 3.3.0 and Xerces 3.1 on Windows.

I have a Qt-based project that I have been building and using Visual 
Studio 2008 for about 8  years. I build and use both 'Debug' and 
'Release' build configurations.

This project uses XSD Tree utility for XML 
serialization/deserialization.  Works great!

I'm migrating to VS2017 and now I'm getting some rather strange LNK2005 
errors on std::string methods and operators.

The code base is broken into two libraries and a bunch of UI 
directories. In Debug build configuration the two libraries are built 
into DLLs and then must be specified in the PATH when running one of the 
UIs. In Release mode everything is compiled statically into a single 
executable.  That builds and works great in the old and new 
environments.

Note the 'Debug' configuration is only used for internal 
development/debugging.  We only ship statically linked Release 
configuration.

The two libraries are 'model' and 'engine'. The 'model' is built first 
and the 'engine' is then built. Code in the 'engine' library uses code 
in the 'model' library.

In 'Debug' configuration, when the 'engine' is linked, I get a bunch of 
the following errors, all dealing with std::string:

   	link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /NODEFAULTLIB:LIBCMT 
/NODEFAULTLIB:LIBCMTD /NODEFAULTLIB:LIBCPMT /NODEFAULTLIB:LIBCPMTD 
/NODEFAULTLIB:MSVCRT /NODEFAULTLIB:MSVCPRT /NODEFAULTLIB:LIBVCRUNTIME 
/NODEFAULTLIB:LIBVCRUNTIMED /NODEFAULTLIB:VCRUNTIME /DLL 
/SUBSYSTEM:WINDOWS /MANIFEST:embed /OUT:lib.debug\flowEngine.dll 
@C:\Users\rjl\AppData\Local\Temp\nmF07.tmp

model.lib(model.dll) : error LNK2005: "public: __thiscall 
std::basic_string<char,struct std::char_traits<char>,class 
std::allocator<char> >::basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >(class 
std::basic_string<char,struct std::char_traits<char>,class 
std::allocator<char> > const &)" 
(??0?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at ABV01@@Z) 
already defined in NamedObject.obj

model.lib(model.dll) : error LNK2005: "public: class 
std::basic_string<char,struct std::char_traits<char>,class 
std::allocator<char> > & __thiscall std::basic_string<char,struct 
std::char_traits<char>,class std::allocator<char> >::operator=(class 
std::basic_string<char,struct std::char_traits<char>,class 
std::allocator<char> > const &)" 
(??4?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAEAAV01 at ABV01@@Z) 
already defined in NamedObject.obj


(NamedObject is in 'engine' library.)

These look like 'std::string (const std::string & other)' and 
'std::string & operator=(const std::string & other)'.

I did a dumpbin /all model.dll on both versions (VS2008 and VS2017) and 
found that, indeed, the VS2017 version included std::string 
implementations, but the VS2008 did not.

If I don't include my XSD stuff (which requires Xerces) in the 'model' 
DLL, I don't have the problem.  I verified that the Xerces (v3.1.1) is 
compiled with /MDd.

I had been using Xerces in 'static debug' with using the 
'-DXERCES_STATIC_LIBRARY' option at compile time and in 'dynamic debug' 
mode (not using the '-DXERCES_STATIC_LIBRARY' compile time option).  
Both versions fail the same (std::string stuff is in the model.dll in 
the VS2017 build.

I did a 'dumpbin' on the Xerces 3.1 debug DLL and it did NOT include the 
std::string class/functions.

Help?



More information about the xsd-users mailing list