Boost logo

Boost Users :

From: Sean Cavanaugh (worksonmymachine_at_[hidden])
Date: 2007-07-07 21:31:04


Ok well in trying to get the serialization library working on my
environment, I am having trouble loading user types via pointer. I've
simplifed the class in question down to a struct containing PODs. Changing
the trivial example to save and load via a local stack variable (i.e. ar &
pass-by-reference) does work, however the real program I am trying to save a
graph of structures foo with pointers to bar, I'm back to the original link
error when trying to load the graph back, even when the root type passed
into serialize is a reference type.

My environment is WinXP w/ msvc8sp1 (aka visual studio 2005 sp1), and boost
1.34

pseudoprogram:

#include <iostream>
#include <fstream>
#include "boost/serialization/access.hpp"
#include "boost/archive/text_iarchive.hpp"
#include "boost/archive/text_oarchive.hpp"

struct MyVector3
{
    float X;
    float Y;
    float Z;

    MyVector3()
    {}
    MyVector3(float x, float y, float z)
        : X(x), Y(y), Z(z)
    {}
};

template<class Archive>
void serialize(Archive & ar, MyVector3& v, const unsigned int version)
{
    ar & v.X;
    ar & v.Y;
    ar & v.Z;
}

int main(int argc, const char** argv)
{
    // Saving via pointer works ---
    std::string filename("TestVector.raw");
    MyVector3* WriteVector = new MyVector3(1.1f, 2.2f, 3.3f);
    std::ofstream ofs(filename.c_str());
    boost::archive::text_oarchive oa(ofs);
    oa & WriteVector;
    ofs.close();

    // Loading via pointer does not ---
    MyVector3* ReadVector = NULL;
    std::ifstream ifs(filename.c_str());
    boost::archive::text_iarchive ia(ifs);
    ia & ReadVector; // <--- commenting this line out makes the link error
go away, but then you can't load anything
    ifs.close();
}

Link error is

error LNK2019: unresolved external symbol "public: class
boost::archive::detail::basic_pointer_iserializer const * __thiscall
boost::archive::detail::basic_iarchive::load_pointer(void * &,class
boost::archive::detail::basic_pointer_iserializer const *,class
boost::archive::detail::basic_pointer_iserializer const *
(__fastcall*)(class boost::serialization::extended_type_info const &))"
(?load_pointer@ basic_iarchive_at_detail@archive_at_boost@@
QAEPBVbasic_pointer_iserializer_at_234@AAPAXPBV5234_at_P6IPBV5234@
ABVextended_type_info_at_serialization@4@@Z_at_Z) referenced in function "public:
static void __fastcall boost::archive::detail::load_pointer_type<class
boost::archive::text_iarchive,struct MyVector3 *>::invoke(class
boost::archive::text_iarchive &,struct MyVector3 * &)"
(?invoke@?$load_pointer_type@ Vtext_iarchive_at_archive@boost@@PAUMyVector3@@@
detail_at_archive@boost@@SIXAAVtext_iarchive_at_34@AAPAUMyVector3@@@Z)

error LNK2019: unresolved external symbol "public: static class
boost::archive::detail::basic_pointer_iserializer const * __fastcall
boost::archive::detail::archive_pointer_iserializer<class
boost::archive::text_iarchive>::find(class
boost::serialization::extended_type_info const &)"
(?find@?$archive_pointer_iserializer@ Vtext_iarchive_at_archive@boost@@@
detail_at_archive@boost@@SIPBVbasic_pointer_iserializer_at_234@
ABVextended_type_info_at_serialization@4@@Z) referenced in function "public:
static void __fastcall boost::archive::detail::load_pointer_type<class
boost::archive::text_iarchive,struct MyVector3 *>::invoke(class
boost::archive::text_iarchive &,struct MyVector3 * &)"
(?invoke@?$load_pointer_type@ Vtext_iarchive_at_archive@boost@@PAUMyVector3@@@
detail_at_archive@boost@@SIXAAVtext_iarchive_at_34@AAPAUMyVector3@@@Z)

error LNK2019: unresolved external symbol "void const * __fastcall
boost::serialization::void_upcast(class
boost::serialization::extended_type_info const &,class
boost::serialization::extended_type_info const &,void const * const,bool)"
(?void_upcast@ serialization_at_boost@@YIPBXABVextended_type_info_at_12@0QBX_N_at_Z)
referenced in function "void * __fastcall
boost::serialization::void_upcast(class
boost::serialization::extended_type_info const &,class
boost::serialization::extended_type_info const &,void * const)"
(?void_upcast@ serialization_at_boost@@YIPAXABVextended_type_info_at_12@0QAX_at_Z)



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