[xsd-users] Shared library and exported symbols problem
Klaim - Joël Lamotte
mjklaim at gmail.com
Tue Jun 28 08:07:20 EDT 2011
Hi,
my project using xsd is still work in progress but the code is available
there : http://code.google.com/p/art-of-sequence/<http://code.google.com/p/art-of-sequence/source/browse/tools/aoslcpp/script/generate_cpp.cfg>
I'm having trouble linking my Qt based executable, aosdesigner, to my
partially xsd generated shared library, aoslcpp.
I can link a simple console test application to the dll (on windows, using
VS2010+SP1).
But trying to link that dll to aosdesigner generates linking errors about
multiple symbols:
2>aoslcpp.lib(aoslcpp.dll) : error LNK2005: "public: __thiscall
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >::~basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >(void)"
(??1?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at XZ)
already defined in Context.obj
2>aoslcpp.lib(aoslcpp.dll) : error LNK2005: "public: __thiscall
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >(char const *)"
(??0?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@QAE at PBD@Z)
already defined in Project.obj
2>E:\Projects\Art_Of_Sequence\public\aos_default\Build\Debug\aosdesigner.exe
: fatal error LNK1169: one or more multiply defined symbols found
At the moment, my way of exporting the symbols is the following :
1. you can read in the xsd code generation configuration file :
http://code.google.com/p/art-of-sequence/source/browse/tools/aoslcpp/script/generate_cpp.cfg
that I set :
# The export/import symbol to use
--export-symbol AOSLCPP_API
and
# Include common compilation config header
--hxx-prologue-file generated_header_prologue.txt
--cxx-prologue-file generated_source_prologue.txt
2. in this prologue file I include aoslcpp/common.h :
http://code.google.com/p/art-of-sequence/source/browse/tools/aoslcpp/script/generated_header_prologue.txt
3. in the header you can read :
http://code.google.com/p/art-of-sequence/source/browse/tools/aoslcpp/include/aoslcpp/common.h
I define AOSLCPP_API to be dllexport or dllimport depending on
AOSLCPP_SOURCE is defined or not.
4. in the cpp prologue file I defined AOSLCPP_SOURCE.
That way the generated code doess export the generated code symbols.
So now I'm not sure where to look for the problem, that's why I expose it
here.
It seems that std::string is exported while it shouldn't be.
My first assumption is that : maybe it's not a good idea to generate inline
functions in case of shared library?
Or maybe there is something I don't know about the generated code or
options?
Any suggestion is welcome, I'm a bit lost by this one because I can't find
exactly where std::string is used in the generated code.
Joël Lamotte
More information about the xsd-users
mailing list