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
#include
#include
#include
#include
#include
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_oarchiveboost::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_oarchiveboost::archive::text_oarchive::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchiveboost::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_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED0Ev[boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x69):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED1Ev[boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x69):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x3d): In function `boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEED2Ev[boost::archive::text_oarchive_implboost::archive::text_oarchive::~text_oarchive_impl()]+0x69):testoa.cpp: more undefined references to `boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()' follow
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive6detail15common_oarchiveINS0_13text_oarchiveEED1Ev[boost::archive::detail::common_oarchiveboost::archive::text_oarchive::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchiveboost::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_oarchiveboost::archive::text_oarchive::~common_oarchive()]+0x18): In function `boost::archive::detail::common_oarchiveboost::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_oarchiveboost::archive::text_oarchive::common_oarchive()]+0xe): In function `boost::archive::detail::common_oarchiveboost::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 const&)]+0x20): In function `void boost::archive::save_access::save_primitive >(boost::archive::text_oarchive&, std::basic_string const&)':
testoa.cpp: undefined reference to
`boost::archive::text_oarchive_implboost::archive::text_oarchive::save(std::basic_string 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::save::invokex(boost::archive::text_oarchive&, Vertex const&)]+0x17): In function `boost::archive::detail::save_non_pointer_type::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_oarchiveboost::archive::text_oarchive::init()]+0x18): In function `boost::archive::detail::common_oarchiveboost::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_oarchiveboost::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_implboost::archive::text_oarchive::text_oarchive_impl(std::basic_ostream&, unsigned int)]+0x21): In function `boost::archive::text_oarchive_implboost::archive::text_oarchive::text_oarchive_impl(std::basic_ostream&, unsigned int)':
testoa.cpp: undefined reference to
`boost::archive::basic_text_oprimitive
>::basic_text_oprimitive(std::basic_ostream&, bool)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive18text_oarchive_implINS0_13text_oarchiveEEC2ERSoj[boost::archive::text_oarchive_implboost::archive::text_oarchive::text_oarchive_impl(std::basic_ostream&, unsigned int)]+0x8c):testoa.cpp: undefined reference to `boost::archive::basic_text_oprimitive >::~basic_text_oprimitive()'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost7archive19basic_text_oarchiveINS0_13text_oarchiveEE13save_overrideERKNS0_15class_name_typeEi[boost::archive::basic_text_oarchiveboost::archive::text_oarchive::save_override(boost::archive::class_name_type const&, int)]+0x54): In function `boost::archive::basic_text_oarchiveboost::archive::text_oarchive::save_override(boost::archive::class_name_type const&, int)':
testoa.cpp: undefined reference to
`boost::archive::text_oarchive_implboost::archive::text_oarchive::save(std::basic_string const&)'
/tmp/ccS4C1Wt.o(.gnu.linkonce.t._ZN5boost15smart_cast_impl9referenceIRNS_7archive13text_oarchiveEE11polymorphic5cross4castINS2_6detail14basic_oarchiveEEES4_RT_[boost::archive::text_oarchive& boost::smart_cast_impl::referenceboost::archive::text_oarchive&::polymorphic::cross::castboost::archive::detail::basic_oarchive(boost::archive::detail::basic_oarchive&)]+0xe): In function `boost::archive::text_oarchive& boost::smart_cast_impl::referenceboost::archive::text_oarchive&::polymorphic::cross::castboost::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