[xsd-users] Compiling to multiple DLLs, duplicate symbols problem
Greg Carter
greg at permedia.ca
Fri Oct 9 11:19:27 EDT 2009
I have a schema spread across about 20 xsd files. I have a number of
custom types. Up until now I have been compiling all the
generated/custom xml code as a static lib. I am now looking at breaking
up the static lib into two shared libs. I have two DLL projects
(windows for now). The first contains the 'base' XML code, the second
uses the first. 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
here geocosmxmllibbasecpp.lib is the base DLL being link to,
DerivativeSchema.obj is part of the DLL attempting to link.
I've been all over the various link options and can't seem to find any
solution. I have the projects setup so that a debug build of DLL 2
links to the .lib produced by the debug build of DLL 1.
This is a sample of the XSD command line for a .xsd file in DLL 1:
$(XSD)\bin\xsd cxx-tree --options-file
"$(ProjectDir)xsdcompileoptionsbase.txt" --output-dir
"$(InputDir)gencode\cpp" --custom-type
OptIterationControlType=/OptIterationControlType_base --hxx-epilogue
"#include \"Optimization_custom.hxx\"" "$(InputDir)OptimizationSchema.xsd"
options file has
--proprietary-license
--generate-intellisense
--generate-serialization
--generate-ostream
--export-maps
--generate-polymorphic
--export-symbol GEOCOSMXMLBASE_SYMBOL_DECL
--hxx-prologue #include <geocosmexportxmlbase.h>
--extern-xml-schema XSDBaseXmlSchema.xsd
The geocosmexportxmlbase.h has:
#ifdef GEOCOSMXMLLIBBASECPP_EXPORTS
#define GEOCOSMXMLBASE_SYMBOL_DECL __declspec(dllexport)
#else
#define GEOCOSMXMLBASE_SYMBOL_DECL __declspec(dllimport)
#endif
and GEOCOSMXMLLIBBASECPP_EXPORTS is defined for the build.
Sample for the second DLL (note uses import-maps):
$(XSD)\bin\xsd.exe cxx-tree --options-file
"$(InputDir)xsdcompileoptions.txt" --output-dir "$(InputDir)gencode\cpp"
"$(InputDir)BurialHistorySchema.xsd"
--proprietary-license
--generate-intellisense
--generate-serialization
--generate-ostream
--generate-polymorphic
--import-maps
--export-symbol GEOCOSMXML_SYMBOL_DECL
--hxx-prologue #include <exportxml.h>
--extern-xml-schema XSDBaseXmlSchema.xsd
and exportxml.h has:
#ifdef GEOCOSMXML_EXPORTS
#define GEOCOSMXML_SYMBOL_DECL __declspec(dllexport)
#else
#define GEOCOSMXML_SYMBOL_DECL __declspec(dllimport)
#endif
I'm using Visual Studio 2005.
Any ideas why I'm getting the duplicate symbols when building the second
DLL?
Thanks
Greg.
More information about the xsd-users
mailing list