Subject : [Serialization] linker problem, serialization method cannot be found.

Hello and thanks for the help I received so far.
here is my current problem:
The class I try to serialize is:
class LIBPALO_NG_CLASS_EXPORT CubeCache : public CUBE_INFO {
public:
friend class boost::serialization::access;
CubeCache();
~CubeCache();
void setSequenceNumber( unsigned int sequenceNumber ) {
m_SequenceNumber = sequenceNumber;
}
unsigned int getSequenceNumber() const {
return m_SequenceNumber;
}
private:
unsigned int m_SequenceNumber;
template<class Archive>
void serialize( Archive &ar, const unsigned int version );
};
the cpp file looks as follows:
#include "CubeCache.h"
#include

In general, templates (like serialize) should not be defined in cpp
files. The compiler must have the definition available when you call
the function so that it can specialize it. If the definition is in a
different cpp file than the call site, then the compiler can not
specialize the function. It will simply try to call it and hope it got
specialized elsewhere; linker errors result.
Your best option whould be to define serialize in the header file, like
[gs]etSequenceNumber.
________________________________
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Oliver Kania
Sent: Wednesday, August 08, 2007 9:48 AM
To: boost-users
Subject: [Boost-users] Subject : [Serialization] linker
problem,serialization method cannot be found.
Hello and thanks for the help I received so far.
here is my current problem:
The class I try to serialize is:
class LIBPALO_NG_CLASS_EXPORT CubeCache : public CUBE_INFO {
public:
friend class boost::serialization::access;
CubeCache();
~CubeCache();
void setSequenceNumber( unsigned int sequenceNumber
) {
m_SequenceNumber = sequenceNumber;
}
unsigned int getSequenceNumber() const {
return m_SequenceNumber;
}
private:
unsigned int m_SequenceNumber;
template<class Archive>
void serialize( Archive &ar, const unsigned int
version );
};
the cpp file looks as follows:
#include "CubeCache.h"
#include

You need to explicitly instantiate the code, see below
Robert Ramey
"Oliver Kania"
participants (3)
-
Andrew Holden
-
Oliver Kania
-
Robert Ramey