Serialization and static Libraries

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Serialization and static Libraries

Boost - Users mailing list

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"

    
class Ping : public Action {

    
    public:

    
    void operator()();
    Ping();
    Ping* clone() const;
    ~Ping();

    
    template <typename Archive>
    void serialize(Archive& ar, const unsigned int);

    
};

    
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"
void Ping::operator()() { }
Ping::Ping() { }
Ping* Ping::clone() const {
Ping* ping = new Ping(*this);
return ping;
}

template <typename Archive> void Ping::serialize(Archive& ar, const unsigned int) { 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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users