Boost logo

Boost :

Subject: Re: [boost] Serialization Link Error
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-01-16 12:05:33


add the following:

#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>

as well as

template void
CommandRequest::serialize<boost::archive::xml_oarchive>(boost::archive::text_oarchive&
archive, const unsigned int version);
template void
CommandRequest::serialize<boost::archive::xml_iarchive>(boost::archive::text_iarchive&
archive, const unsigned int version);

Robert Ramey

Robert Ramey
Venkata (Ravi) Adusumilli wrote:
> Hi,
> BOOST: 1.37
> Linux version 2.6.9-efsm (root_at_vizzini) (gcc version 3.4.6 20060404
> (Red Hat
> 3.4.6-3)) #3 SMP Mon Dec 4 13:14:15 CST 2006
>
> I recieve the following link error:
> *undefined reference to `void
> CommandRequest::serialize<boost::archive::xml_iarchive>(boost::archive::xml_iarchive&,
> unsigned int)'*
>
> while compiling the following class:
>
> ======H======
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/shared_ptr.hpp>
>
> class CommandRequest
> {
> public:
> CommandRequest();
> CommandRequest(int requestID, int commandType);
> ~CommandRequest();
> int requestID() const;
> int commandType() const;
>
> protected:
> int requestIDM;
> int commandTypeM;
> friend class boost::serialization::access;
> template<class A>
> void serialize(A& archive, const unsigned int);
> };
>
> BOOST_SERIALIZATION_SHARED_PTR(CommunicationObjects::CommandRequest)
>
> ======CPP======
> CommandRequest::CommandRequest()
> : requestIDM(0),
> commandTypeM(0)
> {
> }
>
> CommandRequest::CommandRequest(int requestID, int commandType)
> : requestIDM(requestID),
> commandTypeM(commandType)
> {
> }
>
> CommandRequest::~CommandRequest()
> {
> }
>
> int CommandRequest::requestID() const
> {
> return requestIDM;
> }
>
> int CommandRequest::commandType() const
> {
> return commandTypeM;
> }
>
> template<class A>
> void CommandRequest::serialize(A & archive, const unsigned int /*
> version */)
> {
> archive & requestIDM;
> archive & commandTypeM;
> }
> template void
> CommandRequest::serialize<boost::archive::text_oarchive>(boost::archive::text_oarchive&
> archive, const unsigned int version);
> template void
> CommandRequest::serialize<boost::archive::text_iarchive>(boost::archive::text_iarchive&
> archive, const unsigned int version);
>
>
> Please let me know if you can help me out.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk