[serialization] Export macro doesnt work
Hi I was trying to use BOOST_CLASS_EXPORT for all my classes in order to save them but I always got unregistered class error. So I used oa.register_type<object>(); for the class that was causing the error and problem solved. But why doesnt the BOOST_CLASS_EXPORT macro work? Why I need to use oa.register_type<object>(); ? Im using Boost 1.46.1 Thanks
Jari wrote:
Hi I was trying to use BOOST_CLASS_EXPORT for all my classes in order to save them but I always got unregistered class error. So I used oa.register_type<object>(); for the class that was causing the error and problem solved. But why doesnt the BOOST_CLASS_EXPORT macro work?
because you're not using it properly.
Why I need to use oa.register_type<object>(); ?
because you can't get EXPORT to work. Robert Ramey
Im using Boost 1.46.1
Thanks
I have rather simple project considering its not DLL or Lib where I need those exports. And I honestly dont know what the manual is saying about BOOST_CLASS_EXPORT as I have applied it to my project according to my best ability, and it doesnt work. So can you help and give instruction how to use the macro? I have included BOOST_CLASS_EXPORT(SomeClass) after every #include "SomeClass.h" but something is wrong. I dont know what to try. I followed the manual to my best ability. thanks. On Thu, Aug 11, 2011 at 7:51 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Hi I was trying to use BOOST_CLASS_EXPORT for all my classes in order to save them but I always got unregistered class error. So I used oa.register_type<object>(); for the class that was causing the error and problem solved. But why doesnt the BOOST_CLASS_EXPORT macro work?
because you're not using it properly.
Why I need to use oa.register_type<object>(); ?
because you can't get EXPORT to work.
Robert Ramey
Im using Boost 1.46.1
Thanks
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jari wrote:
I have rather simple project considering its not DLL or Lib where I need those exports. And I honestly dont know what the manual is saying about BOOST_CLASS_EXPORT as I have applied it to my project according to my best ability, and it doesnt work.
So can you help and give instruction how to use the macro?
I have included BOOST_CLASS_EXPORT(SomeClass) after every #include "SomeClass.h" but something is wrong.
I dont know what to try.
I followed the manual to my best ability.
Try building one of he demos or tests that come with the library. Make sure that your base classes have at least one virtual function.
thanks.
On Thu, Aug 11, 2011 at 7:51 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Hi I was trying to use BOOST_CLASS_EXPORT for all my classes in order to save them but I always got unregistered class error. So I used oa.register_type<object>(); for the class that was causing the error and problem solved. But why doesnt the BOOST_CLASS_EXPORT macro work?
because you're not using it properly.
Why I need to use oa.register_type<object>(); ?
because you can't get EXPORT to work.
Robert Ramey
Im using Boost 1.46.1
Thanks
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported". Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick. So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is? Im using visual studio 10 express On Thu, Aug 11, 2011 at 10:27 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
I have rather simple project considering its not DLL or Lib where I need those exports. And I honestly dont know what the manual is saying about BOOST_CLASS_EXPORT as I have applied it to my project according to my best ability, and it doesnt work.
So can you help and give instruction how to use the macro?
I have included BOOST_CLASS_EXPORT(SomeClass) after every #include "SomeClass.h" but something is wrong.
I dont know what to try.
I followed the manual to my best ability.
Try building one of he demos or tests that come with the library.
Make sure that your base classes have at least one virtual function.
thanks.
On Thu, Aug 11, 2011 at 7:51 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Hi I was trying to use BOOST_CLASS_EXPORT for all my classes in order to save them but I always got unregistered class error. So I used oa.register_type<object>(); for the class that was causing the error and problem solved. But why doesnt the BOOST_CLASS_EXPORT macro work?
because you're not using it properly.
Why I need to use oa.register_type<object>(); ?
because you can't get EXPORT to work.
Robert Ramey
Im using Boost 1.46.1
Thanks
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not. Robert Ramey
I'm using 1.46.1. So I must use EXPORT_KEY and EXPORT_IMPL ? On Fri, Aug 12, 2011 at 7:33 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Jari, I had the same frustration with Boost.Serialization these days, i know exactly what you're thinking: wtf?! This should be easy! Let me tell you what solved the problem in my case... Suppose you have a derived class D implemented as usual (D.hpp / D.cpp). You need to use the two macros mentioned at the end of the files *outside* any namespace. For instance: //////////////////////////////D.hppnamespace N{ class D : public B { // something };} // namespace N BOOST_CLASS_EXPORT_KEY( N::D ) //////////////////////////////D.cpp#include D.hpp namespace N{ // D implementation} // namespace N BOOST_CLASS_EXPORT_IMPLEMENT( N::D ) You also need to include the boost::archives you're using in D.hpp, since this is the obscure way Boost.Serialization instantiates code for your class. Regards, Júlio. 2011/8/12 Jari <jaristr@gmail.com>
I'm using 1.46.1.
So I must use EXPORT_KEY and EXPORT_IMPL ?
On Fri, Aug 12, 2011 at 7:33 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thx I tried this but it didnt fix the problem.. I traced in basic_serializer_map.cpp and noticed that all the classes are being inserted to m_map , some even multiple times and also lot of null pointers. in Line 46: const std::pair<map_type::iterator, bool> result = m_map.insert(bs); But still get the unexported class error. 2011/8/13 Júlio Hoffimann <julio.hoffimann@gmail.com>:
Hi Jari, I had the same frustration with Boost.Serialization these days, i know exactly what you're thinking: wtf?! This should be easy! Let me tell you what solved the problem in my case... Suppose you have a derived class D implemented as usual (D.hpp / D.cpp). You need to use the two macros mentioned at the end of the files *outside* any namespace. For instance:
//////////////////////////////D.hpp namespace N { class D : public B { // something }; } // namespace N
BOOST_CLASS_EXPORT_KEY( N::D )
//////////////////////////////D.cpp #include D.hpp
namespace N { // D implementation } // namespace N
BOOST_CLASS_EXPORT_IMPLEMENT( N::D )
You also need to include the boost::archives you're using in D.hpp, since this is the obscure way Boost.Serialization instantiates code for your class. Regards, Júlio.
2011/8/12 Jari <jaristr@gmail.com>
I'm using 1.46.1.
So I must use EXPORT_KEY and EXPORT_IMPL ?
On Fri, Aug 12, 2011 at 7:33 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I also noticed that upon program exit basic_serializer_map::erase(const basic_serializer * bs) is being callled at line 75 And it contains all the registered classes. But when serialization call is made before this, in basic_serializer_map::find at line 95 the m_map contains only few entries. Why? the entries seem to be missing from m_map during program execution and only appear there at begin and end... On Mon, Aug 29, 2011 at 1:13 PM, Jari <jaristr@gmail.com> wrote:
Thx I tried this but it didnt fix the problem..
I traced in basic_serializer_map.cpp and noticed that all the classes are being inserted to m_map , some even multiple times and also lot of null pointers.
in Line 46:
const std::pair<map_type::iterator, bool> result = m_map.insert(bs);
But still get the unexported class error.
2011/8/13 Júlio Hoffimann <julio.hoffimann@gmail.com>:
Hi Jari, I had the same frustration with Boost.Serialization these days, i know exactly what you're thinking: wtf?! This should be easy! Let me tell you what solved the problem in my case... Suppose you have a derived class D implemented as usual (D.hpp / D.cpp). You need to use the two macros mentioned at the end of the files *outside* any namespace. For instance:
//////////////////////////////D.hpp namespace N { class D : public B { // something }; } // namespace N
BOOST_CLASS_EXPORT_KEY( N::D )
//////////////////////////////D.cpp #include D.hpp
namespace N { // D implementation } // namespace N
BOOST_CLASS_EXPORT_IMPLEMENT( N::D )
You also need to include the boost::archives you're using in D.hpp, since this is the obscure way Boost.Serialization instantiates code for your class. Regards, Júlio.
2011/8/12 Jari <jaristr@gmail.com>
I'm using 1.46.1.
So I must use EXPORT_KEY and EXPORT_IMPL ?
On Fri, Aug 12, 2011 at 7:33 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hello why cant i still make it work? On Mon, Aug 29, 2011 at 1:22 PM, Jari <jaristr@gmail.com> wrote:
I also noticed that upon program exit basic_serializer_map::erase(const basic_serializer * bs) is being callled at line 75
And it contains all the registered classes.
But when serialization call is made before this, in basic_serializer_map::find at line 95
the m_map contains only few entries.
Why?
the entries seem to be missing from m_map during program execution and only appear there at begin and end...
On Mon, Aug 29, 2011 at 1:13 PM, Jari <jaristr@gmail.com> wrote:
Thx I tried this but it didnt fix the problem..
I traced in basic_serializer_map.cpp and noticed that all the classes are being inserted to m_map , some even multiple times and also lot of null pointers.
in Line 46:
const std::pair<map_type::iterator, bool> result = m_map.insert(bs);
But still get the unexported class error.
2011/8/13 Júlio Hoffimann <julio.hoffimann@gmail.com>:
Hi Jari, I had the same frustration with Boost.Serialization these days, i know exactly what you're thinking: wtf?! This should be easy! Let me tell you what solved the problem in my case... Suppose you have a derived class D implemented as usual (D.hpp / D.cpp). You need to use the two macros mentioned at the end of the files *outside* any namespace. For instance:
//////////////////////////////D.hpp namespace N { class D : public B { // something }; } // namespace N
BOOST_CLASS_EXPORT_KEY( N::D )
//////////////////////////////D.cpp #include D.hpp
namespace N { // D implementation } // namespace N
BOOST_CLASS_EXPORT_IMPLEMENT( N::D )
You also need to include the boost::archives you're using in D.hpp, since this is the obscure way Boost.Serialization instantiates code for your class. Regards, Júlio.
2011/8/12 Jari <jaristr@gmail.com>
I'm using 1.46.1.
So I must use EXPORT_KEY and EXPORT_IMPL ?
On Fri, Aug 12, 2011 at 7:33 AM, Robert Ramey <ramey@rrsd.com> wrote:
Jari wrote:
Ok I tried one test code and it worked, but when I moved the all the classes in header file and but the export macro in cpp file it fails with "derived class not registered or exported".
Then I moved the export macros to main.cpp right before main() and before the saving/loading calls, and that did the trick.
So it seems export's need to be in same CPP file where the loading/saving starts? Or is it in same cpp where the function is?
Im using visual studio 10 express
The question of export being in the *.ccp and/or in the header was a confusion which has only been resolved in recent versions of the library. Now there is EXPORT_KEY and EXPORT_IMPL... Which resolves the ocnfusion. I don't know which version of boost you're using so I don't know if this addresses your issue or not.
Robert Ramey
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Jari
-
Júlio Hoffimann
-
Robert Ramey