Sry but I do not understand. I do specify the implementation with

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

as you suggest and as I have written in example 1.
Then I write

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
            );

to make the compiler generate code for these two template parameters.
It works for me in other cases and it is what the documentation says.
I dont think that removing the two template-specification could solve the issue,
since the template function-definition is not included in any header file.
There must be some misunderstanding.

Kind regards, Oliver

On Nov 29, 2007 5:27 PM, Robert Ramey <ramey@rrsd.com> wrote:
This is a C++ syntax issue.
 
The first example explicitly instantiates the serialize declaration without specifying its implementation
which leads to an undefined symbol. just use:
 
template<class Archive>
        void PaloClient::serialize( Archive &ar, const unsigned int version ) {
            ar & m_PaloClientImpl;
        }

and the appropriate code wil be instantiated if and only if it is actually invoked.
 
Robert Ramey
 
 
"Oliver Kania" <kania.oliver@googlemail.com> wrote in message news:1262c4ee0711290739x12408875u39e54bbe9effb093@mail.gmail.com...
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@archive@boost@@@PaloClient@palo@jedox@@AAEXAAVtext_oarchive@archive@boost@@I@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@archive@boost@@VPaloClient@palo@jedox@@@access@serialization@boost@@SAXAAVtext_oarchive@archive@2@AAVPaloClient@palo@jedox@@I@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 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