Boost logo

Boost Users :

From: Lorenzo Cavallaro (sullivan_at_[hidden])
Date: 2007-08-14 20:11:46


Dear Boost list,

   I'm trying to use the boost serialization class to serialize some objects.

   Unfortunately, I keep running into the same issue (compilation error) that
   I report here below for clarity

   $ g++-3.4 -fPIC -O2 -g -I. -c model.cpp -o model.o
 
   /usr/include/boost/serialization/access.hpp: In static member function
+`static void boost::serialization::access::serialize(Archive&, T&, unsigned
+int) [with Archive = boost::archive::text_oarchive, T =
+__gnu_cxx::hash_multimap<addr_t, Events*, __gnu_cxx::hash<unsigned int>,
+eqaddr, std::allocator<Events*> >]':
/usr/include/boost/serialization/serialization.hpp:81: instantiated from `void
+boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive =
+boost::archive::text_oarchive, T = __gnu_cxx::hash_multimap<addr_t, Events*,
+__gnu_cxx::hash<unsigned int>, eqaddr, std::allocator<Events*> >]'
/usr/include/boost/serialization/serialization.hpp:140: instantiated from
+`void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with
+Archive = boost::archive::text_oarchive, T = __gnu_cxx::hash_multimap<addr_t,
+Events*, __gnu_cxx::hash<unsigned int>, eqaddr, std::allocator<Events*> >]'
/usr/include/boost/archive/detail/oserializer.hpp:148: instantiated from `void
+boost::archive::detail::oserializer<Archive,
+T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*)
+const [with Archive = boost::archive::text_oarchive, T =
+__gnu_cxx::hash_multimap<addr_t, Events*, __gnu_cxx::hash<unsigned int>,
+eqaddr, std::allocator<Events*> >]'
model.cpp:599: instantiated from here
/usr/include/boost/serialization/access.hpp:109: error: 'class
+__gnu_cxx::hash_multimap<addr_t, Events*, __gnu_cxx::hash<unsigned int>,
+eqaddr, std::allocator<Events*> >' has no member named 'serialize'
make: *** [model.o] Error 1

   I've looked for this error on Internet and I found out that a discussion on
   the boost mailing list dated back on 2005
   (http://lists.boost.org/boost-users/2005/08/13183.php).

   I tried making those changes but nothing happened and I still have the
   reported compilation error.

   For the sake of clarity, here's a snippet of the code I'm trying to compile

   #include <boost/archive/text_iarchive.hpp>
   #include <boost/archive/text_oarchive.hpp>
   #include <boost/serialization/base_object.hpp>
   #include <boost/serialization/utility.hpp>
   #include <boost/serialization/list.hpp>
   #include <boost/serialization/vector.hpp>
   #include <boost/serialization/hash_map.hpp>
   #include <ext/hash_map>
   using namespace std;
   using namespace __gnu_cxx;

   struct eqaddr {
      bool operator()(addr_t ret1, addr_t ret2) const {
         return ret1 == ret2;
      }
   };

   typedef hash_multimap<addr_t, Events *, hash<addr_t>, eqaddr> model_t;

   class ModelMap
   {

      friend class boost::serialization::access;
      template<class Archive>
      void
      serialize(Archive & ar, const unsigned int file_version)
      {
         ar & map;
      }

      public:

      model_t map;

      ModelMap() { }
      ~ModelMap() { }
 
   };

   I'm using libboost-serialization 1.33.1-10 (debian)

   Any idea on how to fix this? Am I doing something wrong?

TIA, bye
Lorenzo

-- 
Lorenzo `Gigi Sullivan' Cavallaro <sullivan_at_[hidden]>
GPG key at http://security.dico.unimi.it/~sullivan/sullivan.asc
Until I loved, life had no beauty;
I did not know I lived until I had loved. (Theodor Korner)
See the reality in your eyes, when the hate makes you blind. (A.H.X)

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