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

Greg Carter greg at permedia.ca
Wed Feb 17 17:21:06 EST 2010


Hi Boris,

I missed this when you first posted it, I will give it a try on Windows. 
However I am having a problem when I try to compile on Linux which I 
think is related to this, or at least to the exporting of XSD base 
template symbols.

I'm trying to build the equivalent of my geocosmxmllibbasecpp.dll on 
Linux as a shared lib. When I try to build I get this error
explicit instantiation of ‘class 
xsd::cxx::tree::simple_type<xsd::cxx::tree::_type>’ in namespace 
‘xml_schema’ (which does not enclose namespace ‘xsd::cxx::tree’)

At each point in my XSDBaseXmlSchema.hxx where a line like:

template class GEOCOSMXMLBASE_SYMBOL_DECL ::xsd::cxx::tree::simple_type< 
type >;

occurs.

For my linux build GEOCOSMXMLBASE_SYMBOL_DECL is defined as nothing:
#define GEOCOSMXMLBASE_SYMBOL_DECL

I'm on centos 5.4,
g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
xsd version xsd-3.3.0.b1-i686-linux-gnu, although the files were 
generated (including XSDBaseXmlSchema.hxx) on Windows using xsd version 
xsd-3.3.0.b1-i686-windows.

I'm using Eclipse to build, the exact command is:
make all
Building file: ../xmlschema/gencode/cpp/DistributionCorrelationSchema.cxx
Invoking: GCC C++ Compiler
g++ -DGEOCOSMXMLLIBBASECPP_EXPORTS=1 
-I"/opt/xsd-3.3.0.b1-i686-linux-gnu/libxsd" 
-I"/opt/xerces-c-3.1.0-x86-linux-gcc-3.4/include" 
-I"/mnt/src/geocosm/geocosmxmllibbasecpp" 
-I"/mnt/src/geocosm/xmlschema/gencode/cpp" -O0 -g3 -Wall -c 
-fmessage-length=0 -MMD -MP 
-MF"xmlschema/gencode/cpp/DistributionCorrelationSchema.d" 
-MT"xmlschema/gencode/cpp/DistributionCorrelationSchema.d" 
-o"xmlschema/gencode/cpp/DistributionCorrelationSchema.o" 
"../xmlschema/gencode/cpp/DistributionCorrelationSchema.cxx"

../xmlschema/gencode/cpp/XSDBaseXmlSchema.hxx:82: error: explicit 
instantiation of ‘class 
xsd::cxx::tree::simple_type<xsd::cxx::tree::_type>’ in namespace 
‘xml_schema’ (which does not enclose namespace ‘xsd::cxx::tree’)
../xmlschema/gencode/cpp/XSDBaseXmlSchema.hxx:126: error: explicit 
instantiation of ‘class xsd::cxx::tree::string<char, 
xsd::cxx::tree::simple_type<xsd::cxx::tree::_type> >’ in namespace 
‘xml_schema’ (which does not enclose namespace ‘xsd::cxx::tree’)
<48 more errors all in XSDBaseXmlSchema.hxx>

Any ideas?

Boris Kolpackov wrote:
> Hi Greg,
>
>   
> Based on this understanding I was able to work around the problem
> in your case by adding the following code at the end of exportxml.h:
>
> #include <xsd/cxx/tree/containers.hxx>
>
> namespace xsd
> {
>   namespace cxx
>   {
>     namespace tree
>     {
>       template class __declspec(dllimport) sequence<int>;
>     }
>   }
> }
>
>   



More information about the xsd-users mailing list