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


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 {


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

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



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_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?



Boost-users mailing list
[hidden email]