[xsd-users] Compiling to multiple DLLs, duplicate symbols problem
Boris Kolpackov
boris at codesynthesis.com
Fri Oct 9 11:52:34 EDT 2009
Hi Greg,
Greg Carter <greg at permedia.ca> writes:
> In Release mode the dlls build and execute fine. In debug mode when I
> build my second dll (which links to the first) I get duplicate link
> errors (error LNK2005). An example is:
>
> geocosmxmllibbasecpp.lib(geocosmxmllibbasecpp.dll) : error LNK2005:
> "public: virtual __thiscall xsd::cxx::tree::string<char,class
> xsd::cxx::tree::simple_type<class xsd::cxx::tree::_type>
> >::~string<char,class xsd::cxx::tree::simple_type<class
> xsd::cxx::tree::_type> >(void)"
> (??1?$string at DV?$simple_type at V_type@tree at cxx@xsd@@@tree at cxx@xsd@@@tree at cxx@xsd@@UAE at XZ)
> already defined in DerivativeSchema.obj
>
> [...]
>
> I'm using Visual Studio 2005.
> Any ideas why I'm getting the duplicate symbols when building the second
> DLL?
Yes, I think I have seen this already. In the release build these functions
are eliminated by the optimizer but in the debug build they are there and
for some reason VC++ doesn't sort it out as it should (note that ~string()
above is synthesized by the C++ compiler; the source code never actually
defines one).
The solution for this problem is to export symbols for the built-in types
from the "base" DLL and import them in all dependant DLLs and executables.
To automate this we added a new option, --export-xml-schema, for the next
release of XSD. You can give it a try by downloading this pre-release
binary:
http://www.codesynthesis.com/~boris/tmp/xsd-3.3.0.a5-i686-windows.zip
In your case, you will need to add
--export-xml-schema --export-symbol GEOCOSMXMLBASE_SYMBOL_DECL
when generating the code for the XML Schema namespace (i.e., "compiling"
XSDBaseXmlSchema.xsd).
Let me know if this works for you.
Boris
More information about the xsd-users
mailing list