Honestly I have been looking for a solution for hours before I made this post. I am not so familiar with boost, the only module I use is serialization so maybe my error is obvious but I went through all the doc on boost.org without luck.

I should have been more descriptive I my first post. I does not work because I get unresolved externals on the base class save / load functions when I implement the derived class save/load functions. I am using the intrusive version of serialization so their should be no particular namespace requirement. Here is a simplified example of my problem:

///////////////////////////////////// A.h
Class A:
{
    friend class boost::serialization::access;
    template<class Archive>
    void save(Archive & ar, const unsigned int version) const;
    template<class Archive>
    void load(Archive & ar, const unsigned int version);

    BOOST_SERIALIZATION_SPLIT_MEMBER()

};
/////////////////////////////////////

///////////////////////////////////// B.h
class B: public A
{
    friend class boost::serialization::access;
    template<class Archive>
    void save(Archive & ar, const unsigned int version) const;
   
    template<class Archive>
    void load(Archive & ar, const unsigned int  file_version );

    BOOST_SERIALIZATION_SPLIT_MEMBER()
}
BOOST_CLASS_EXPORT_GUID(B, "B")
/////////////////////////////////////

///////////////////////////////////// A.cpp
template<class Archive>
void A::save(Archive & ar, const unsigned int version) const
{
    ar & var1;
}

template<class Archive>
void A::load(Archive & ar, const unsigned int  file_version )
{
    ar & var;
    somestuff();
}   
/////////////////////////////////////

///////////////////////////////////// B.cpp
template<class Archive>
void B::save(Archive & ar, const unsigned int version) const
{
    ar & boost::serialization::base_object<A>(*this);
    ar & var2;
}

template<class Archive>
void B::load(Archive & ar, const unsigned int  file_version )
{
    ar & boost::serialization::base_object<A>(*this);
    ar & var2;
    morestuff();
}
 /////////////////////////////////////

If I don't put the two implementation of serialization of A and B in the same file I get this error:

error LNK2019: unresolved external symbol "public: void __thiscall A::save<class boost::archive::text_oarchive> ...
error LNK2019: unresolved external symbol "public: void __thiscall A::load<class boost::archive::text_iarchive> ...

Feel free to redirect me to some more documentation, I read most of boost.org serialization section but maybe their are other places to look at.

I am also having problem figuring out the when to use BOOST_CLASS_EXPORT vs BOOST_CLASS_EXPORT_GUID vs ar.register_types.

Thank you for your help.




On 9/30/07, Robert Ramey <ramey@rrsd.com> wrote:
A easy way to fix this would be to put the serialization code in the source file instead of the header file but I can't get this to work...
 
There is no reason why this shouldn't work.  Invest some effort figuring out why it won't link.  Check namespaces.
 
Robert Ramey
"Fred Lupien" <fred.lupien@gmail.com> wrote in message news:32e6d6bf0709300738u77850377t2bf40ec5501b882f@mail.gmail.com ...
Hi,
 
   I am using the boost serialization library in a personal project and ran into a recursive include problem. Class A serialize an object of class B and class B also serialize an object of class A. So class A must be a complete type in class B and class B must be a complete type in class A, hence the recursive include problem. I always end up with unresolved externals if the body of my serialization functions are not within the header file. Any way around this beside switching to non-intrusive serialization?

thanx!

--
Frédérick Martel-Lupien
Étudiant en Génie Informatique
Université de Sherbrooke
fred.lupien@gmail.com


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



--
Frédérick Martel-Lupien
Étudiant en Génie Informatique
Université de Sherbrooke
fred.lupien@gmail.com