Prev: Low memory conditions (was: Re: CoW and reference counting in the STL)
Next: Error :: compile serilization program given in boost library examples
From: Pallav singh on 30 Apr 2010 02:22 Hi i am trying to compile serilization program given in boost library examples but it giving me following error Thanks pallav ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <fstream> // include headers that implement a archive in simple text format #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/list.hpp> ///////////////////////////////////////////////////////////// // gps coordinate // // illustrates serialization for a simple type // class gps_position { private: friend class boost::serialization::access; // When the class Archive corresponds to an output archive, the // & operator is defined similar to <<. Likewise, when the class Archive // is a type of input archive the & operator is defined similar to >>. template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & degrees; ar & minutes; ar & seconds; } int degrees; int minutes; float seconds; public: gps_position(){}; gps_position(int d, int m, float s) : degrees(d), minutes(m), seconds(s) {} }; int main() { // create and open a character archive for output std::ofstream ofs("filename"); // create class instance const gps_position g(35, 59, 24.567f); // save data to archive { boost::archive::text_oarchive oa(ofs); // write class instance to archive oa << g; // archive and stream closed when destructors are called } // ... some time later restore the class instance to its orginal state gps_position newg; { // create and open an archive for input std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); // read class state from archive ia >> newg; // archive and stream closed when destructors are called } return 0; } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ [pallavs(a)vl-pallavs ~/Pallav]$ g++ -g serilization1.cc -I /usr/include/ boost/serialization -I /usr/include/boost/archive In file included from /usr/include/boost/config.hpp:35, from /usr/include/boost/archive/text_oarchive.hpp:22, from serilization1.cc:4: /usr/include/boost/config/compiler/gcc.hpp:92:7: warning: #warning "Unknown compiler version - please run the configure tests and report the results" /tmp/ccYF8vTo.o: In function `extended_type_info_typeid_0': /usr/include/boost/serialization/extended_type_info_typeid.hpp:65: undefined reference to `boost::serialization::detail::extended_type_info_typeid_0::type_info_key' /tmp/ccYF8vTo.o: In function `boost::archive::text_iarchive& boost::smart_cast_impl::reference<boost::archive::text_iarchive&>::polymorphic::cross::cast<boost::archive::detail::basic_iarchive>(boost::archive::detail::basic_iarchive&)': /usr/include/boost/smart_cast.hpp:77: undefined reference to `typeinfo for boost::archive::detail::basic_iarchive' /tmp/ccYF8vTo.o: In function `boost::archive::text_oarchive& boost::smart_cast_impl::reference<boost::archive::text_oarchive&>::polymorphic::cross::cast<boost::archive::detail::basic_oarchive>(boost::archive::detail::basic_oarchive&)': /usr/include/boost/smart_cast.hpp:77: undefined reference to `typeinfo for boost::archive::detail::basic_oarchive' /tmp/ccYF8vTo.o: In function `~common_oarchive': /usr/include/boost/archive/detail/common_oarchive.hpp:31: undefined reference to `boost::archive::detail::basic_oarchive::~basic_oarchive()' /tmp/ccYF8vTo.o: In function `~text_oarchive_impl': /usr/include/boost/archive/text_oarchive.hpp:39: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' /usr/include/boost/archive/text_oarchive.hpp:39: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' /usr/include/boost/archive/text_oarchive.hpp:39: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' /usr/include/boost/archive/text_oarchive.hpp:39: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Jeff Flinn on 1 May 2010 05:27
Pallav singh wrote: > Hi > i am trying to compile serilization program given in boost library > examples > but it giving me following error .... > [pallavs(a)vl-pallavs ~/Pallav]$ g++ -g serilization1.cc -I /usr/include/ > boost/serialization -I /usr/include/boost/archive > In file included from /usr/include/boost/config.hpp:35, > from /usr/include/boost/archive/text_oarchive.hpp:22, > from serilization1.cc:4: > /usr/include/boost/config/compiler/gcc.hpp:92:7: warning: #warning > "Unknown compiler version - please run the configure tests and report > the results" Well, I'd start with this one, and make sure that boost was properly installed. You may get better support from the boost users mailing list. Jeff -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |