[xsd-users] xml_schema::exception, linux, shared libraries, and visibility=hidden

Greg Carter greg at permedia.ca
Wed Apr 21 14:49:15 EDT 2010


Boris Kolpackov wrote:
> Hi Greg,
> This is already done when you generate the XML Schema namespace into
> a separate file (--generate-xml-schema option) and specify the
> --export-xml-schema and --export-symbol options, as in:
>
> xsd cxx-tree --generate-xml-schema --export-xml-schema --export-symbol \
> SCHEMA_EXPORT xml-schema.xsd
> The xml-schema.hxx file then contains:
>
> template class SCHEMA_EXPORT exception< char >;
>
> So I believe your setup should work provided that:
>
> 1. the XML Schema namespace was compiled as above and
>
>   
Hi Boris,
I think I have the above correct, here is how I compile my schema 
namespace to a single header file:

$(XSD)\bin\xsd.exe cxx-tree --proprietary-license  --generate-xml-schema 
--export-xml-schema --export-symbol GEOCOSMXMLBASE_SYMBOL_DECL 
--hxx-prologue "#include <geocosmexportxmlbase.h>" 
--generate-intellisense --output-dir "$(InputDir)gencode\cpp" 
--generate-serialization --generate-ostream 
"$(InputDir)XSDBaseXmlSchema.xsd"

My geocosmexportxmlbase.h has
#define GEOCOSMXMLBASE_SYMBOL_DECL __attribute__ 
((__visibility__("default")))
and the generated code (XSDBaseXmlSchema.hxx) has
template class GEOCOSMXMLBASE_SYMBOL_DECL exception< char >;

> 2. all other schemas are compiled with --extern-xml-schema to use 
>    xml-schema.hxx and
> 3. SCHEMA_EXPORT is set to visibility=default when building all the
>    libraries.
>
>   
This is the xsdcompileoptionsbase.txt options file I use for the base xml:
--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

This is a typical command line for the schemas:
$(XSD)\bin\xsd.exe cxx-tree --options-file 
"$(ProjectDir)xsdcompileoptionsbase.txt" --output-dir 
"$(InputDir)gencode\cpp" "$(InputDir)BurialHistorySchema.xsd"

xsdcompileoptions.txt options file for my dependent xml lib
--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

exportxml.h has:
#define GEOCOSMXML_SYMBOL_DECL __attribute__ ((__visibility__("default")))

Here is a typical command line for the dependent schemas
$(XSD)\bin\xsd.exe cxx-tree --options-file 
"$(InputDir)xsdcompileoptions.txt" --output-dir "$(InputDir)gencode\cpp" 
"$(InputDir)DistributionSchema.xsd"

I'm using XSD on Windows to generate the code, compile is done on linux 
(CentOS 5.4)

For the two xml libs, I compile with visibility=default, I did try 
hidden, and the program ran and found all symbols but I still had the 
exception issue.  I'll try to see if I can replicate with a simple test 
app...


> Can you check that the above conditions are met in your setup? If that's
> the case, then it would be helpful if you could create a small test case
> that reproduces this problem.
>
> As a side node, we are about to start final testing for XSD 3.3.0 so if 
> there is indeed a problem here and you would like to have it resolved in
> 3.3.0, we need to move fast with this.
>
> Boris
>
>   



More information about the xsd-users mailing list