Boost logo

Boost Users :

Subject: Re: [Boost-users] Serialization of derived class in a plugin
From: Jean-Charles Quillet (jeancharles.quillet_at_[hidden])
Date: 2009-12-21 08:16:55


Hi Robert,

Thinking about this again, I found out what was wrong with my code. I was
linking statically with the serialization library resulting two instances of
the singleton managing types (one in my main app and one in the dll). Damned
!

Using the flag BOOST_ALL_DYN_LINK to make it links dynamically solves my
problem and it works great now. No more "Unregistered class" exception.
Brilliant !

Thanks for your time and such a great library !

Jean-Charles

On Mon, Dec 21, 2009 at 9:29 AM, Jean-Charles Quillet <
jeancharles.quillet_at_[hidden]> wrote:

> Ok,
> even if it's not in the 1.42 release I'd be very interested by a patch
> making it works as soon as it's available. In the meantime I'll try to use
> the version 1.37, on this web page someone reported that this feature was
> working:
>
> https://kyuu.co.uk/article/6
>
> Jean-Charles
>
>
> On Sun, Dec 20, 2009 at 10:25 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>
>> OK - found it now.
>>
>> I've invested a little time to look into it. A couple of things
>>
>> a) turns out I never really built/ran this this test. It depended on my
>> getting
>> more understanding to how to test a dll with boost and setting my msvc IDE
>> to handle this. Lately I got this squared away but I hadn't run the test.
>>
>> a) the test uses the polymorphic_archive. This seemed to confuse me
>> (mostly
>> because the word "polymorphic" is all over the place) so I changed it to
>> text_?archive.
>>
>> b) So I ran the test and found a couple of dumb bugs. Need to link to the
>> dll_polymorphic_derived2.dll, etc.
>>
>> c) needed to add a marcro
>> BOOST_SERIALIZATION_FACTORY_0(polymorphic_derived2)
>> to the header so the plugin factory would work.
>>
>> d) After all this - the program builds and runs - but has fails to recover
>> the proper
>> pointer. I"m looking into this. I'll uploaded updated test to trunk when
>> it's done.
>> I do not think this fix will make it into it into boost 1.42.
>>
>> Robert Ramey
>>
>>
>> "Jean-Charles Quillet" <jeancharles.quillet_at_[hidden]> wrote in message
>> news:3dd8f9530912200857y985aa2cqee9931d44f4c94f7_at_mail.gmail.com...
>> I'm working with the latest version 1.41
>>
>> You can have a look here, I'm not sure to understand the boost repository,
>> but it looks quite similar of what I have:
>>
>>
>> https://svn.boost.org/trac/boost/browser/branches/release/libs/serialization/test
>>
>> You'll find the source file I'm talking about (it's actually
>> test_dll_plugin.cpp and not test_plugin_dll.cpp but you'd have made the
>> correction yourself) along with the bjam file with the commented line.
>>
>> Jean-Charles
>>
>> On Sun, Dec 20, 2009 at 5:43 PM, Robert Ramey <ramey_at_[hidden]> wrote:
>>
>>> I can't find test_plugin_dll.cpp in my latest package. How about
>>> sending me a copy.
>>>
>>> Robert Ramey
>>>
>>>
>>> "Jean-Charles Quillet" <jeancharles.quillet_at_[hidden]> wrote in message
>>> news:3dd8f9530912200316r36477536sd6958d55b13aaff1_at_mail.gmail.com...
>>> Ok,
>>>
>>> I understand that it should work somehow, so I'm doing something wrong.
>>> I've checked it and I got quite a few virtual abstract functions in my main
>>> class overridden in the derived classes.
>>>
>>> I've seen all these demo and test. And the one that comes closer to my
>>> problem is definetly test_plugin_dll.cpp Unfortunaltly it is commented in
>>> the Jam file and when I uncommented the line, it won't compile.
>>> How can I compile it ?
>>> Thanks for your help,
>>>
>>> Jean-Charles
>>>
>>> On Sun, Dec 20, 2009 at 12:19 AM, Robert Ramey <ramey_at_[hidden]> wrote:
>>>
>>>> note that there a few demos of this facility example/demo_???. Also
>>>> demo_pimple might be helpful.
>>>>
>>>> Also there is test_exported_dll and test_simple_dll.
>>>>
>>>> Check these out and see if it helps.
>>>>
>>>> Also, quadriple check that your base class has at least one virtual
>>>> function.
>>>>
>>>> Robert Ramey
>>>>
>>>>
>>>> "Jean-Charles Quillet" <jeancharles.quillet_at_[hidden]> wrote in message
>>>> news:3dd8f9530912190643k77ed2c0co2aeabf7d41af35a2_at_mail.gmail.com...
>>>> Hi,
>>>>
>>>> I've been using the boost serialization on many projects. But I can't
>>>> manage to make it work on my current project.
>>>>
>>>> Basically, I've a main application and an abstract class located in a
>>>> separate dll. The application loads dynamically plugins which defines
>>>> classes derived from the abstract class. Then I'm trying to serialize a
>>>> class created by a plugin using a pointer to the abstract class, I always
>>>> get a "Unregistered class" exception. I've used the BOOST_CLASS_EXPORT macro
>>>> in the plugins trying to make the boost serialization library aware of my
>>>> classes without any success so far.
>>>>
>>>> Looking in the source directory and specially in the "test" directory,
>>>> I've seen that what I'm trying to do is the same as the test described by
>>>> the file test_dll_plugin.cpp, unfortunately, it seems the test is not
>>>> compiled and I can't manage to make it link without error.
>>>> So my main concern is: is this feature supposed to be working ? If not
>>>> I'll have to review my design. If it does what is the magic to make it work
>>>> (like how to compile test_dll_plugin.cpp or another simple working example)
>>>> ?
>>>> Thanks for any help,
>>>>
>>>> Jean-Charles
>>>>
>>>> ------------------------------
>>>>
>>>> _______________________________________________
>>>> Boost-users mailing list
>>>> Boost-users_at_[hidden]
>>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>>
>>>>
>>>> _______________________________________________
>>>> Boost-users mailing list
>>>> Boost-users_at_[hidden]
>>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>>
>>>
>>> ------------------------------
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>
>>
>> _______________________________________________
>> 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