Boost logo

Boost Users :

From: Dan Thill (dgt_at_[hidden])
Date: 2008-04-13 14:27:46


> I've updated the advice on using BOOST_CLASS_EXPORT. The new
> advice is described in the documentation in the trunk. This will require
> moving some
> macros between source modules (*.cpp and *.hpp files).
>
> In exchange, you'll get
>
> a) a more carefully thought out way to handle exports.
> b) the ability to include serialization code in DLLS with little or no
> suprises.
> c) serialization code will be thread safe - without any locking required.

Robert,

I've read the new documentation and while it fixes the compilation
errors, I still get runtime unregistered_class exceptions. Here's my
general setup, briefly.

MyClass.h
-------
class MyClass : public SomeBase { .... };

MyClassSZ.h
---------
#include <MyClass.h>

template<Archive>
void serialize( Archive&, MyClass&, ... )

ClassSZ.cpp
-----------
#include <MyClassSZ.h>
#include <boost/archive/...> // All archive types I'm going to use
#include <boost/serialization/export.hpp>

BOOST_CLASS_EXPORT(MyClass);

void serialize( Archive&, MyClass&, unsigned int )
{
    // perform serialization. No void_cast_register is done
    // because I *always* serialize via a base class pointer.
    // also, I do not serialize the base object as there is
    // no data in it.
}

// Explicitly instantiate above function for each archive type

template
void serialize<xml_iarchive>(xml_iarchive&, MyClass&, unsigned int);

template
void serialize<xml_oarchive>(xml_iarchive&, MyClass&, unsigned int);

// ... etc.

----------------------------------------

All of my ClassSZ.cpp files are compiled and statically linked into a
library. Then, in the application:

main.cpp
--------
#include ... // archive type that I want
#include <MyClassSZ.h>

// Create archive and serialize a MyClass via SomeBase ptr)

----------------------------------------

Is it a possibility that the linker is not linking in the
guid_initializer code? For this particular build type, I'm not even
doing optimizations... let alone link-time code generation. This is on
MSVC80.

Thanks,
Dan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net