Boost logo

Boost Users :

From: Jeshua Bratman (bratman_at_[hidden])
Date: 2007-08-09 18:02:36


First of all, thank you for the quick and helpful reply!

I did as you suggested as to serializing the pointer. It does make much more
sense that way, and now it throws an useful exception when I try this
serialization:

  terminate called after throwing an instance of
'boost::archive::archive_exception'
    what(): unregistered class

So clearly I need to export the class as you said because the derived class
has not been registered.

Robert Ramey wrote:
>
>> I can't use the BOOST_CLASS_EXPORT_GUID(derived,
>> "derived") macro discussed on that page because main does not know
>> what a derived object is (this is the whole point of having this
>> plugin system).
>
> In order to make this link and run correctly as it stands, you'll have to
> use EXPORT. To make it work as desiired for plugins, include it
> in the modules which implement the plug - in - not the main and
> not the base class.
>

I tried exporting the derived class in derived.cpp:

     BOOST_CLASS_EXPORT_GUID(derived,"derived")

But then when I compile the shared library I get about 100 compile errors,
many similiar to this:

     error: incomplete type
'boost::serialization::extended_type_info_null<derived>' used in nested name
specifier

Do you know what this could be about? I'm guessing it is just something
simple I'm not thinking about, but I can't seem to get it to export.

This seems very similar to someone else's unresolved problem:
http://www.nabble.com/-Serialization--Problem-serialization-of-derived-classes-tf2960557.html#a8282732
http://www.nabble.com/-Serialization--Problem-serialization-of-derived-classes-tf2960557.html#a8282732

I am using gentoo with
gcc (GCC) 4.1.1 (Gentoo 4.1.1-r3),
and
boost-1.33.1-r1

Jeshua

EDIT:

In fact, this trivial piece of code does not compile:

#include <boost/serialization/base_object.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>

//BASE
class base
{
public:
  virtual void virt_func() = 0;
};
BOOST_IS_ABSTRACT(base);

//DERIVED
class derived : public base
{
public:
  void virt_func() {}
};
BOOST_CLASS_EXPORT_GUID(derived,"derived")

//MAIN
int main(){return 0;}

-- 
View this message in context: http://www.nabble.com/Boost-Serialization-with-a-dynamically-loaded-shared-library-tf4238910.html#a12081468
Sent from the Boost - Users mailing list archive at Nabble.com.

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