|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-03-12 20:26:03
Are you sure this worked before? That would surprise me.
The problem is that template that implement the "export" functionality are
instantiated for each archive type previously "seen" in the header. So
including the following
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/export.hpp>
BOOST_CLASS_EXPORT(C)
in multiple modules is going to produce multiple symbols at link time.
My suggestion would be to include the archive headers only in the modules
that actually invoke serialization. And that be only in one module. My
intention was that each class header contain BOOST_CLASS_EXPORT for its
classes and the the "main" or other module (see demo_pimpl) that actually
invoked the serialiation would include the headers for the archive classes
that are desired. This makes it easy to switch between archive types for
things like debugging, etc.
Robert Ramey
Vladimir Prus wrote:
>> Hello,
>> I've have a header file like this:
>>
>> namespace lvk { namespace nm_model { namespace runtime {
>> class IntTraceItem {};
>> }}}
>>
>> BOOST_CLASS_EXPORT(lvk::nm_model::runtime::IntTraceItem);
>>
>> The header is included in two files. It used to work before, but
>> I've just updated to CVS state of the serialization lib, and get:
>>
>>
src/runtime/bin/gcc/debug/threading-multi/TraceArbiter.o(.bss+0x0):src/runti
me/TraceArbiter.cpp:16:
>> multiple definition of
>>
`boost::archive::detail::guid_initializer<lvk::nm_model::runtime::IntTraceIt
em>::instance'
>>
src/runtime/bin/gcc/debug/threading-multi/Trace.o(.bss+0x0):src/runtime/Trac
e.cpp:21:
>> first defined here
>>
>> I attach the testcase. When I run
>>
>> g++ -I ~/Work/boost-rc s1.cpp s2.cpp
>>
>> the first error is about duplicate symbols.
>>
>> Am I doing something wrong or is this a regression?
>>
>> - Volodya
>>
>
>
>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk