[xsd-users] Double definitions when using DLLs

alexander.gosling at kongsberg.com alexander.gosling at kongsberg.com
Mon May 5 12:37:52 EDT 2014


Hello,
We are in the process of porting a SW system using CodeSynthesis from Visual Studio 2005 to Visual Studio 2012. We have experienced here that CodeSynthesis works fine if the libraries containing generated code are linked statically to the executable. If we however produce the libraries with generated code as DLLs, we run into a problem that we believe is the same as is widely discussed on the net concerning inheritance of std::string.

In xsd-3.3.0-i686-windows\libxsd\xsd\cxx\tree\types.hxx the class xsd::cxx:tree:string is declared inheriting from std::string. When variables from this class are used in the interface of generated classes as parameters and return values, and these generated classes are a part of the interface of the DLL (the methods are declared with dll_export/dll_import as part of the signature) this leads to doubly defined std::npos when linking the library (DLL) to the executable. This happens if the main program also uses std::string, and I believe also if I link more than one library of CodeSynthesis generated code with the characteristics described above.

You will find a lot of references to the problem of doubly defined std::npos on using classes that inherit from std::string by searching for "std::string already defined".
>From what I have read about the problem I see no other solution than reimplementing xsd::cxx:tree:string so that it creates a facade to a contained std::string instead of inheriting std::string. But we are open to any solution that is simple from the user perspective.

--
alex


________________________________

CONFIDENTIALITY
This e-mail and any attachment contain KONGSBERG information which may be proprietary, confidential or subject to export regulations, and is only meant for the intended recipient(s). Any disclosure, copying, distribution or use is prohibited, if not otherwise explicitly agreed with KONGSBERG. If received in error, please delete it immediately from your system and notify the sender properly.


More information about the xsd-users mailing list