|
Boost Users : |
From: Christian Widmer (cwidmer_at_[hidden])
Date: 2008-03-14 11:27:03
Dear Robert,
thank you for your reply. After struggling with some other issues for a
couple days, I've compiled boost-1.34 with the serialization patch from
your website, as you suggested.
In deed, the "unregistered class" problem disappeared, but was
unfortunately replaced by a "unregistered void cast" exception when
trying to serialize across shared-object boundaries.
All classes are registered using BOOST_CLASS_EXPORT in their respective
.cpp file, yet I can't get it to work. I attached a piece of my code to
this email. The attached archive contains the following files:
- Classifier.h
- Classifier.cpp
- Labels.h
- Labels.cpp
The class CClassifier has a field labels of type CLabels. The classes
are contained in two separate shared-objects. When trying to serialize
an object of type CClassifier, an exception gets thrown when attempting
to serialize the field labels. Any ideas?
Best regards,
Christian Widmer
Robert Ramey wrote:
> This is possible and I have tested such a facility. I haven't had time
> to move the latest version into the trunk but one can find at www.rrsd.com
> However, in order to do this, you will have to know how to use
> EXPORT correctly which does require a close reading of the manual.
> Sorry about that.
>
> RObert Ramey
>
>
> Christian Widmer wrote:
>
>> Hi,
>>
>>
>> I'm trying to use boost to serialize a machine learning library that
>> I'm working with. It all worked out very conveniently, but it seems
>> now, that I have hit a dead end. I've been looking on the net but
>> couldn't find any information that worked for me, so here we go:
>>
>> The problem is, that the library consists of several modules, which
>> are dynamically linked. For instance the class KernelMachine has a
>> field kernel of type Kernel, which is contained in a separate module
>> (in the sense of a shared object).
>>
>> The following code compiles, but when I try to serialize a
>> CKernelMachine object I get an "unregistered_class" error. (CKernel
>> does serialize fine, when called directly)
>>
>> class CKernelMachine : public CClassifier
>> {
>>
>> private:
>>
>> friend class boost::serialization::access;
>> template<class Archive>
>> void serialize(Archive & ar, const unsigned int version)
>> {
>> ar & boost::serialization::base_object<CClassifier>(*this);
>>
>> ar.register_type(static_cast<CGaussianKernel *>(NULL));
>> ar & kernel;
>>
>> std::cout << "done CKernelMachine" << std::endl;
>> }
>>
>> protected:
>> CKernel* kernel;
>> };
>>
>> I found some threads that pointed me towards BOOST_CLASS_EXPORT, but
>> I'm not exactly sure how to use it.
>>
>>
>> So my question is - is it in principle even possible to serialize
>> across module (shared-object) boundaries.
>>
>> If so, how should I go about? Any pointers would be greatly
>> appreciated.
>>
>>
>> - Chris
>>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
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