[xsd-users] exported types with restrictions, based on xs:string - link time, multiple defined symbols error

Emmanuil Tsagarakis emmanuil.tsagarakis at gmail.com
Fri May 20 03:44:35 EDT 2022


Hello!

Has anyone faced this issue before?
I'm developing a program that links with two dynamic libraries.
Each library contains one or more xsd schemas.
I need to export/import the generated classes from those dlls, so in xsd
compiler I use the Export Symbol:

--export-symbol "EC3_DLL_DECL" for the first one and

--export-symbol "EC5_DLL_DECL" for the second

The above export symbols are defined as:

#ifdef _EC2DLL
#define EC2_DLL_DECL __declspec(dllimport)
#else
#define EC2_DLL_DECL __declspec(dllexport)
#endif

and:

#ifdef _EC3DLL
#define EC3_DLL_DECL __declspec(dllimport)
#else
#define EC3_DLL_DECL __declspec(dllexport)
#endif

I add both _EC2DLL and _EC3DLL in my main program C++ preprocessor
definitions.

Both schemas contain elements with restrictions, based on xs:string like
the following:

<xs:complexType name="rc_norm_t">
  <xs:sequence>
    <xs:element name="type" minOccurs="1" maxOccurs="1">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="EC2"/>
          <xs:enumeration value="EAK"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:element>
  </xs:sequence>
</xs:complexType>

The problem is that, when I link the 2 libs against the main exe program, I
get errors for multiple defined symbols, like the following:

LibPost.lib(LibPost.dll) : error LNK2005: "public: __cdecl
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator<wchar_t> >::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >(class
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class
std::allocator<wchar_t> > const &)" (??0?$basic_string at _WU?$char_traits@
_W at std@@V?$allocator at _W@2@@std@@QEAA at AEBV01@@Z) already defined in
add_brace_links.obj

It seems like for types with restrictions, std::basic_string is exported
multiple times from both dlls.

Is anyone aware of this issue?
Has anyone faced the problem before?
Any help or suggestion is highly appreciated!

Thank you in advance,
Emmanuil


More information about the xsd-users mailing list