|
Boost Users : |
From: Feng Wang (fengw_at_[hidden])
Date: 2006-01-02 18:53:32
Dear All,
I got a trouble with boost::serialization library and need your
help.
1) I am working with FC4 on my laptop. GCC 4.0.2 is known handle
this library pretty well according to yesterdays's report.
http://boost.sourceforge.net/regression-logs/cs-Linux.html
2) try to test the basic sample obtained on webpage posted by
Jeff
Cogswell:
#include <fstream>
#include <iostream>
//#include <boost/serialization/base_object.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/detail/basic_iarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/access.hpp>
using namespace std;
class Vertex {
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & x;
ar & y;
}
double x;
double y;
public:
Vertex() {} // Serialization requires a default constructor
Vertex(double newX, double newY) : x(newX), y(newY) {}
double getX() const { return x; }
double getY() const { return y; }
void dump() {
cout << x << " " << y << endl;
}
};
int main()
{
Vertex v1(1.5, 2.5);
std::ofstream ofs("myfile.vtx");
boost::archive::text_oarchive oa(ofs);
oa << v1;
ofs.close();
return 0;
}
3) try to compile and link it by the following command:
g++ -lboost_serialization testoa.cpp -otestoa
and got a bunch of errors.
4) The errors looks as this:
/tmp/ccS4C1Wt.o(.gnu.linkonce.r._ZTIN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEE[typeinfo for boost::archive::detail::common_oarchive<boost::archive::text_oarchive>]+0x10): undefined reference to `typeinfo for boost::archive::detail::basic_oarchive'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost13serialization6detail27extended_type_info_typeid_0C2Ev[boost::serialization::detail::extended_type_info_typeid_0::extended_type_info_typeid_0()]+0x7): In function `boost::serialization::detail::extended_type_info_typeid_0::extended_type_info_typeid_0()':
testoa.cpp: undefined reference to
`boost::serialization::detail::extended_type_info_typeid_0::type_info_key'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED2Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
testoa.cpp: undefined reference to
`boost::archive::detail::basic_oarchive::~basic_oarchive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED0Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive<std::basic_ostream<char,
std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED0Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x69):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive<std::basic_ostream<char,
std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x69):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive<std::basic_ostream<char,
std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::~text_oarchive_impl()]+0x69):testoa.cpp: more undefined references to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()' follow
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED1Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
testoa.cpp: undefined reference to
`boost::archive::detail::basic_oarchive::~basic_oarchive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED0Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::~common_oarchive()':
testoa.cpp: undefined reference to
`boost::archive::detail::basic_oarchive::~basic_oarchive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEEC2Ev[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::common_oarchive()]+0xe): In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::common_oarchive()':
testoa.cpp: undefined reference to
`boost::archive::detail::basic_oarchive::basic_oarchive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive11save_access14save_primitiveINS0_13text_oarchiveESsEEvRT_RKT0_[void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x20): In function `void boost::archive::save_access::save_primitive<boost::archive::text_oarchive, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(boost::archive::text_oarchive&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
testoa.cpp: undefined reference to
`boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost13serialization25extended_type_info_typeidIK6VertexEC1Ev[boost::serialization::extended_type_info_typeid<Vertex const>::extended_type_info_typeid()]+0x28): In function `boost::serialization::extended_type_info_typeid<Vertex const>::extended_type_info_typeid()':
testoa.cpp: undefined reference to
`boost::serialization::extended_type_info::self_register()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail21save_non_pointer_typeINS0_13text_oarchiveE6VertexE4save7invokexERS3_RKS4_[boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, Vertex>::save::invokex(boost::archive::text_oarchive&, Vertex const&)]+0x17): In function `boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, Vertex>::save::invokex(boost::archive::text_oarchive&, Vertex const&)':
testoa.cpp: undefined reference to
`boost::archive::detail::basic_oarchive::save_object(void
const*,
boost::archive::detail::basic_oserializer const&)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE4initEv[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::init()]+0x18): In function `boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::init()':
testoa.cpp: undefined reference to
`boost::archive::ARCHIVE_SIGNATURE'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEE4initEv[boost::archive::detail::common_oarchive<boost::archive::text_oarchive>::init()]+0x98):testoa.cpp: undefined reference to `boost::archive::ARCHIVE_VERSION'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEEC2ERSoj[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)]+0x21): In function `boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive<std::basic_ostream<char,
std::char_traits<char> >
>::basic_text_oprimitive(std::basic_ostream<char,
std::char_traits<char>
>&, bool)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEEC2ERSoj[boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::text_oarchive_impl(std::basic_ostream<char, std::char_traits<char> >&, unsigned int)]+0x8c):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive<std::basic_ostream<char, std::char_traits<char> > >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive19basic_text_oarchiveINS0_13text_oarchiveEE13save_overrideERKNS0_15class_name_typeEi[boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::save_override(boost::archive::class_name_type const&, int)]+0x54): In function `boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::save_override(boost::archive::class_name_type const&, int)':
testoa.cpp: undefined reference to
`boost::archive::text_oarchive_impl<boost::archive::text_oarchive>::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost15smart_cast_impl9referenceIRNS_7archive13text_oarchiveEE11polymorphic5cross4castINS2_6detail14basic_oarchiveEEES4_RT_[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&)]+0xe): 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&)':
testoa.cpp: undefined reference to `typeinfo for
boost::archive::detail::basic_oarchive'
collect2: ld returned 1 exit status
5) Another compile and link issue was talked about on boost
user-list half a year
ago(http://lists.boost.org/boost-users/2005/05/11624.php)
However, I could not decipher the my correct answer from that.
My error looks different from the errors posted there.
6) Thanks in advance for your time and help with this issue. I
think I might miss some basic points on this library.
Henry .K. Wang
Jan 2, 2006
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