[xsd-users] Compiling to multiple DLLs, duplicate symbols problem

Greg Carter greg at permedia.ca
Thu Feb 18 17:06:43 EST 2010


Hi Boris,

I just tried the manual work around of removing the --extern-xml-schema 
option then regenerating the code (regen on Windows FWIW), then compiled 
on Linux.  I'm running into another problem with a symbol that is 
getting defined in both the base header file (the one produced by 
--generate-xml-schema) and in the headers of the generated code.

First the section of XSDBaseXmlSchema.hxx (generated by the 
--generate-xml-schema)
// DOM interaction.
  //
  namespace dom
  {
    // Automatic pointer for DOMDocument.
    //
    using ::xsd::cxx::xml::dom::auto_ptr;

    // DOM user data key for back pointers to tree nodes.
    //
    const XMLCh* const tree_node_key = 
::xsd::cxx::tree::user_data_keys::node;  <--- this line here
  }

now the section from one of my code files generated from my schema:
 // DOM interaction.
  //
  namespace dom
  {
    // Automatic pointer for DOMDocument.
    //
    using ::xsd::cxx::xml::dom::auto_ptr;

#ifndef XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
#define XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA
    // DOM user data key for back pointers to tree nodes.
    //
    const XMLCh* const tree_node_key = 
::xsd::cxx::tree::user_data_keys::node;  <--- this line
#endif
  }

The tree_node_key ends up defined multiple times.  Note FWIW I only run 
into this when attempting to compile one of my "child" libs.  The base 
lib compiles fine.  So for some reason when I ran xsd across my XSD 
files that are in the child lib this bit of code got added.

I got past this by putting a similar ifdef in the XSDBaseXmlSchema.hxx 
as found in the child lib headers and was able to build both the 
base/child libs on linux.  Still a way off from using them... but 
hopefully they are built OK now.

Ideally I'll end up applying your fix, as removing the 
--extern-xml-schema option is a manual process (I have to put it back in 
to get a proper build for Windows)... when you have a fix let me know 
and I'll try it out.

Thanks
Greg.

Boris Kolpackov wrote:
> Yes, this is a Microsoft-specific extension (which may or may not work
> with the symbol visibility feature in GCC). I was too quick to say that
> the same generated code can be used across all the platforms; there are
> currently some options (such as --export-xml-schema) that result in
> platform-specific code. I will think of a way to work around this 
> (probably wrap it in #ifndef NO_EXPORT_XML_SCHEMA so that the code 
> can be used on other platforms with just a simple define).
>
>   
>> I think this is related to the --export-maps/--import-maps option.  Do  
>> you see any way around this?
>>     
>
> I think this particular case is caused by --export-xml-schema but these
> two options are also MS (and starting from 3.3.0, GCC) -specific.
>
>
>   
>> If I remove the --export-maps/--import-maps options and regenerate 
>> my code for a Linux build, will I still be able to separate the 
>> generated code into multiple shared libs (Linux)?
>>     
>
> Yes, sure. On Linux everything will work out of the box without any
> extra effort from your side.
>
> Boris
>
>   



More information about the xsd-users mailing list