Boost logo

Boost Users :

From: Wolfgang Meyerle (wolfgang.meyerle_at_[hidden])
Date: 2021-01-20 15:58:18


Hi,

probably has been asked already thousand of times but I'm stuck
currently with some code:

Assuming I have the following files (The Base class Action is serialized
in the same way):

File: Ping.h

#include"Action.h"

classPing:publicAction{

public:

voidoperator()();

Ping();

Ping*clone()const;

~Ping();

template<typenameArchive>

voidserialize(Archive&ar,constunsignedint);

};

BOOST_CLASS_EXPORT_KEY2(Ping,"Ping");

File: Ping.cpp

#include"Ping.h"

#include<iostream>

#include<boost/serialization/base_object.hpp>

#include<boost/serialization/export.hpp>
#include<boost/serialization/tracking.hpp>

#include"Action.h"

#include"system.h"

#include"pong.h"

#include"serializerdeserializer.h"

#include"system.h"
#include"connection.h" #include"communication.h"
voidPing::operator()(){ }
Ping::Ping() { }
Ping*Ping::clone()const{
Ping*ping=newPing(*this);
returnping;
}

template<typenameArchive>
voidPing::serialize(Archive&ar,constunsignedint){
ar&BOOST_SERIALIZATION_BASE_OBJECT_NVP(Action); }

Ping::~Ping(){}

BOOST_CLASS_EXPORT_IMPLEMENT(Ping);

BOOST_CLASS_TRACKING(Ping,boost::serialization::track_never);

If I now compile the project into a library. And link this library to a
different project.

If I try to serialize the class now it doesn't work.

I get the following error:

unregistered class - derived class not registered or exported

According to the boost documentation I need to use
BOOST_CLASS_EXPORT_KEY in the header file and
BOOST_CLASS_EXPORT_IMPLEMENT in the corresponding cpp file.

What did I miss?

Regards,

Wolfgang



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