
Hi, I still have the issue described below. If someone could give me a hint why using BOOST_CLASS_EXPORT from Boost.Serialization give me linker errors I would greatly appreciate it! The small code that reproduces the problem is available at http://pastebin.com/m5eebb3b7 Thanks, Chris Christoph Mayer schrieb:
Hi,
when using Boost v1.37 I get a problem with the serialization library that did not appear before. The following linker error occurs:
undefined reference to `boost::archive::detail::archive_pointer_oserializer<boost::archive::detail:
polymorphic_oarchive_route<boost::archive::binary_oarchive_impl<boost::arch
ive::binary_oarchive, char, std::char_traits<char> > >
:~archive_pointer_oserializer()' The error does not appear when I omit the class registration using BOOST_CLASS_EXPORT_GUID.
Robert Ramey schrieb:
Support for EXPORT was clarified and improved in 1.37. The documention was updated to reflect this. Double check the documentation in this area and verify that your usage if EXPORT is consistent with the information found there.
Thanks for your reply. Unfortunately I have been struggling with this now for weeks and can't get it to work.
I created a minimal sample that reproduces the linker error on Boost 1.38. The sample is attached below and available at http://pastebin.com/m5eebb3b7
This code does not compile on Boost 1.38 but on Boost 1.34. There is one special one that is shown as ///////// COMMENT THE NEXT LINE TO MAKE IT COMPILE!!! If I comment the next line in the sample the code compiler with Boost 1.38. But then I get an exception saying "unregistered class".
If possible I would like to use BOOST_CLASS_EXPORT as it fits nicely into my project structure.
I am aware that the there are much unused #includes, as I assembled this sample from a larger project.
Any hints on how the inclusion of the BOOST_CLASS_EXPORT causes problems here is welcome!
Thanks, Chris
////////////////////////////////////////////// // ---------------> Message
#include <boost/serialization/serialization.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/assume_abstract.hpp>
class Message { friend class boost::serialization::access; public: Message() : type(123) { }
virtual ~Message(){ }
virtual void virtualfunc () = 0;
private: int type;
template<class Archive> void serialize(Archive& x, const unsigned int version){ x & type; } };
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Message);
////////////////////////////////////////////// // ----------------> MessageTimer
#include <boost/serialization/string.hpp>
using std::string;
class MessageTimer : public Message { friend class boost::serialization::access; public: MessageTimer(int x) : event(x){ }
MessageTimer() : event(0){ }
virtual ~MessageTimer(){ }
virtual void virtualfunc(){ }
private: int event;
template<class Archive> void serialize(Archive& y, const unsigned int version){ boost::serialization::base_object<Message>(*this); boost::serialization::void_cast_register<MessageTimer, Message> (); y & event; } };
////////////////////////////////////////////// // ----------------> Serialization
#include <iostream> #include <sstream> #include <ios> #include <boost/archive/polymorphic_binary_oarchive.hpp> #include <boost/archive/polymorphic_binary_iarchive.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/serialization.hpp> #include <boost/serialization/tracking.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/factory.hpp>
///////// COMMENT THE NEXT LINE TO MAKE IT COMPILE!!! BOOST_CLASS_EXPORT(MessageTimer); ///////////////////////////////////////////////////////
BOOST_CLASS_TRACKING(MessageTimer, boost::serialization::track_never);
int main(){
Message* msg = new MessageTimer( 5 );
std::stringstream archiveStream (std::ios_base::binary | std::ios_base::out); { boost::archive::polymorphic_binary_oarchive outputArchive (archiveStream); outputArchive & msg; }
string data= archiveStream.str (); std::cout << data << std::endl;
return 0; }
Robert Ramy
Christoph Mayer wrote:
Hi,
when using Boost v1.37 I get a problem with the serialization library that did not appear before. The following linker error occurs:
undefined reference to `boost::archive::detail::archive_pointer_oserializer<boost::archive::detail:
polymorphic_oarchive_route<boost::archive::binary_oarchive_impl<boost::arch
ive::binary_oarchive, char, std::char_traits<char> > >
:~archive_pointer_oserializer()' The error does not appear when I omit the class registration using BOOST_CLASS_EXPORT_GUID.
As far as I understand the error, the linker can't find the d'tor for the singleton where the classes get registered. Below you can find the complete linker output.
Any help is appreciated, Chris
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Dipl.-Inform. Christoph P. Mayer Institute of Telematics, University of Karlsruhe (TH) Zirkel 2, 76128 Karlsruhe, Germany Phone: +49 721 608 6415, Email: mayer@tm.uka.de Web: http://www.tm.uka.de/~mayer/