Boost logo

Boost Users :

From: Oliver Kania (kania.oliver_at_[hidden])
Date: 2007-11-29 10:39:04


Hello !

When linking a program that consists only of main.cpp with a library that
serializes
a class "Palo Cllient" I get the following message (sry for the mess):

==================================================
 error LNK2019: unresolved external symbol "private: void __thiscall
jedox::palo::PaloClient::serialize<class
boost::archive::text_oarchive>(class boost::archive::text_oarchive
&,unsigned int)" (??$serialize@ Vtext_oarchive_at_archive@boost@@@
PaloClient_at_palo@jedox@@AAEXAAVtext_oarchive_at_archive@boost@@I_at_Z) referenced
in function "public: static void __cdecl
boost::serialization::access::serialize<class
boost::archive::text_oarchive,class jedox::palo::PaloClient>(class
boost::archive::text_oarchive &,class jedox::palo::PaloClient &,unsigned
int)" (??$serialize@ Vtext_oarchive_at_archive@boost@@VPaloClient_at_palo@jedox@@@
access_at_serialization@boost@@SAXAAVtext_oarchive_at_archive@2_at_AAVPaloClient@
palo_at_jedox@@I_at_Z)
==================================================

This happens even though I do NOT explicitly serialize anything.
Main.cpp includes:

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

For the class PaloClient, I do use the Pimpl idiom and serialize as it is
recommended
in the documentation:

PaloClient.cpp:

--------------------------------------------------------------

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/scoped_ptr.hpp>

....

template<class Archive>
        void PaloClient::serialize( Archive &ar, const unsigned int version
) {
            ar & m_PaloClientImpl;
        }

template void PaloClient::serialize<boost::archive::text_iarchive>(
            boost::archive::text_iarchive & ar,
            const unsigned int file_version
            );

        template void PaloClient::serialize<boost::archive::text_oarchive>(
            boost::archive::text_oarchive & ar,
            const unsigned int file_version
            );
------------------------------------------------------------------------

Now, when I change this to

        void PaloClient::serialize(boost::archive::text_iarchive & ar, const
unsigned int file_version) {
            ar & m_PaloClientImpl;
        }

        void PaloClient::serialize (boost::archive::text_oarchive & ar,
const unsigned int file_version) {
                ar & m_PaloClientImpl;
        }

The linkage error disappears. I guess this is a Visual C++ compiler problem
but
I wanted to post this in case someone else has similar problems.

Kind regards, Oliver

PS: Thanks for this great serialization library, it saved me many weeks of
programming.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net