[boost][serialization] How to implement serialization classes in two DLLs

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[boost][serialization] How to implement serialization classes in two DLLs

Marc VIALA

Hi,

 

I’m very sorry to post the message hereafter a second time, but I’ve not received any reply, maybe I’ve missed it.

 

Any workaround or recommendations will be welcome because we are right now surrounded in our software development.

 

Thanks in advance.    

 

Marc VIALA

 

 

 

After few hour on the subject, I’m would like to have some explanations & recommendations one the boost serialization library. To explain, my problem, you will find hereafter a VC++ 7.1 project that demonstrates it.

 

Problem Description

We have involved in a large project with for example two DLLs libraries: LibA and LibB. These libraries define & implement one class, let’s say libA::A and libB::B. These two classes can be serialized through boost serialization engine.

 

The interfaces for the two classes are the same:

 

----------------------

struct LIBA_API A

{

  std::vector<double> my_vector ;

 

private:

  friend class boost::serialization::access;

  template<class Archive>

    void save(Archive & ar, const unsigned int version) const ;

  template<class Archive>

    void load(Archive & ar, const unsigned int version) ;

 

  BOOST_SERIALIZATION_SPLIT_MEMBER()

};

 

  LIBA_API

    void save(const libA::A* pObj, std::ostream& os) ;

  LIBA_API

    void load(libA::A* &pObj, std::istream& is) ;

}; // Namespace libA

----------------------

 

The two free functions save() and load() are defined to be able to serialize the class libA::A (respectively the class libB::B).

 

When, we try to use these interfaces in an EXE application:

 

----------------------

#include <LibA/A.h>

#include <LibB/B.h>

 

#include <boost/filesystem/path.hpp>

#include <boost/filesystem/fstream.hpp>

 

#pragma comment(lib, "liba_d.lib")

#pragma comment(lib, "libb_d.lib")

 

int

main(int argc, char* argv[])

{

  libA::A a;

  libA::save(&a, boost::filesystem::ofstream("a.xml"));

 

  libB::B b;

  libB::save(&b, boost::filesystem::ofstream("b.xml")); // -> Assert in debug mode

 

  return 0;

}

----------------------

 

The figure hereafter describes the relationships between LibA, LibB and EXE application:

                      ------------                              ------------

                      |       LibA      |                              |       LibB       |

                      ------------                               ------------

                                             \                          /

                                               \                       /                                                      

                                                  Exe Application

 

We have to face to an assert in debug mode generate by the file boost::serialization::extended_type_info.cpp, line#71. This assert happens during the instance serialization of class libB:B.

 

Recently, there are some posts on this subject, but I would like to known how I can deal with this assert? Is it possible to avoid it by a code organisation? Is it possible to comment this assert?

 

To have a concrete answer, I have joined my complete VC++7.1 project.

 

Thanks in advance for your help.

 

Development Platform

WindowsXP

VC++ 7.1

Boost 1.33.1

 

Marc Viala

[hidden email]

 

 

 


SerializationTest.zip (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [boost][serialization] How to implement serializationclasses in two DLLs

Robert Ramey
Truth is I havn't gotten to it.  Sorry.  Its a very tricky area.  One thing you might want to look at is the test which shows separate compilation.   This avoids having the "same" code in both the executable and the dll which might help.
 
Robert Ramey
 
"Marc Viala" <[hidden email]> wrote in message <A href="news:92DC6B03E56CE74D9463089D3BF0A71068B911@serveur.acticm.com">news:92DC6B03E56CE74D9463089D3BF0A71068B911@......

Hi,

 

I’m very sorry to post the message hereafter a second time, but I’ve not received any reply, maybe I’ve missed it.

 

Any workaround or recommendations will be welcome because we are right now surrounded in our software development.

 

Thanks in advance.    

 

Marc VIALA

 

 

 

After few hour on the subject, I’m would like to have some explanations & recommendations one the boost serialization library. To explain, my problem, you will find hereafter a VC++ 7.1 project that demonstrates it.

 

Problem Description

We have involved in a large project with for example two DLLs libraries: LibA and LibB. These libraries define & implement one class, let’s say libA::A and libB::B. These two classes can be serialized through boost serialization engine.

 

The interfaces for the two classes are the same:

 

----------------------

struct LIBA_API A

{

  std::vector<double> my_vector ;

 

private:

  friend class boost::serialization::access;

  template<class Archive>

    void save(Archive & ar, const unsigned int version) const ;

  template<class Archive>

    void load(Archive & ar, const unsigned int version) ;

 

  BOOST_SERIALIZATION_SPLIT_MEMBER()

};

 

  LIBA_API

    void save(const libA::A* pObj, std::ostream& os) ;

  LIBA_API

    void load(libA::A* &pObj, std::istream& is) ;

}; // Namespace libA

----------------------

 

The two free functions save() and load() are defined to be able to serialize the class libA::A (respectively the class libB::B).

 

When, we try to use these interfaces in an EXE application:

 

----------------------

#include <LibA/A.h>

#include <LibB/B.h>

 

#include <boost/filesystem/path.hpp>

#include <boost/filesystem/fstream.hpp>

 

#pragma comment(lib, "liba_d.lib")

#pragma comment(lib, "libb_d.lib")

 

int

main(int argc, char* argv[])

{

  libA::A a;

  libA::save(&a, boost::filesystem::ofstream("a.xml"));

 

  libB::B b;

  libB::save(&b, boost::filesystem::ofstream("b.xml")); // -> Assert in debug mode

 

  return 0;

}

----------------------

 

The figure hereafter describes the relationships between LibA, LibB and EXE application:

                      ------------                              ------------

                      |       LibA      |                              |       LibB       |

                      ------------                               ------------

                                             \                          /

                                               \                       /                                                      

                                                  Exe Application

 

We have to face to an assert in debug mode generate by the file boost::serialization::extended_type_info.cpp, line#71. This assert happens during the instance serialization of class libB:B.

 

Recently, there are some posts on this subject, but I would like to known how I can deal with this assert? Is it possible to avoid it by a code organisation? Is it possible to comment this assert?

 

To have a concrete answer, I have joined my complete VC++7.1 project.

 

Thanks in advance for your help.

 

Development Platform

WindowsXP

VC++ 7.1

Boost 1.33.1

 

Marc Viala

[hidden email]

 

 

 


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [boost][serialization] How to implementserializationclasses in two DLLs

Marc VIALA

Hi Robert,

 

Thanks to handle my request; I’ve looked the source directory “test” and “examples” of boost::serialization ver#1.33.1 and I didn’t find the test that you’ve pointed in your reply.

 

What’s the name of the test demonstrating separate compilation?

 

Marc Viala

[hidden email]


De : [hidden email] [mailto:[hidden email]] De la part de Robert Ramey
Envoyé : mercredi 1 février 2006 22:59
À : [hidden email]
Objet : Re: [Boost-users] [boost][serialization] How to implementserializationclasses in two DLLs

 

Truth is I havn't gotten to it.  Sorry.  Its a very tricky area.  One thing you might want to look at is the test which shows separate compilation.   This avoids having the "same" code in both the executable and the dll which might help.

 

Robert Ramey

 

"Marc Viala" <[hidden email]> wrote in message <a href="news:92DC6B03E56CE74D9463089D3BF0A71068B911@serveur.acticm.com">news:92DC6B03E56CE74D9463089D3BF0A71068B911@......

Hi,

 

I’m very sorry to post the message hereafter a second time, but I’ve not received any reply, maybe I’ve missed it.

 

Any workaround or recommendations will be welcome because we are right now surrounded in our software development.

 

Thanks in advance.             

 

Marc VIALA

 

 

 

After few hour on the subject, I’m would like to have some explanations & recommendations one the boost serialization library. To explain, my problem, you will find hereafter a VC++ 7.1 project that demonstrates it.

 

Problem Description

We have involved in a large project with for example two DLLs libraries: LibA and LibB. These libraries define & implement one class, let’s say libA::A and libB::B. These two classes can be serialized through boost serialization engine.

 

The interfaces for the two classes are the same:

 

----------------------

struct LIBA_API A

{

  std::vector<double> my_vector ;

 

private:

  friend class boost::serialization::access;

  template<class Archive>

    void save(Archive & ar, const unsigned int version) const ;

  template<class Archive>

    void load(Archive & ar, const unsigned int version) ;

 

  BOOST_SERIALIZATION_SPLIT_MEMBER()

};

 

  LIBA_API

    void save(const libA::A* pObj, std::ostream& os) ;

  LIBA_API

    void load(libA::A* &pObj, std::istream& is) ;

}; // Namespace libA

----------------------

 

The two free functions save() and load() are defined to be able to serialize the class libA::A (respectively the class libB::B).

 

When, we try to use these interfaces in an EXE application:

 

----------------------

#include <LibA/A.h>

#include <LibB/B.h>

 

#include <boost/filesystem/path.hpp>

#include <boost/filesystem/fstream.hpp>

 

#pragma comment(lib, "liba_d.lib")

#pragma comment(lib, "libb_d.lib")

 

int

main(int argc, char* argv[])

{

  libA::A a;

  libA::save(&a, boost::filesystem::ofstream("a.xml"));

 

  libB::B b;

  libB::save(&b, boost::filesystem::ofstream("b.xml")); // -> Assert in debug mode

 

  return 0;

}

----------------------

 

The figure hereafter describes the relationships between LibA, LibB and EXE application:

                      ------------                              ------------

                      |       LibA      |                              |       LibB       |

                      ------------                               ------------

                                             \                          /

                                               \                       /                                                      

                                                  Exe Application

 

We have to face to an assert in debug mode generate by the file boost::serialization::extended_type_info.cpp, line#71. This assert happens during the instance serialization of class libB:B.

 

Recently, there are some posts on this subject, but I would like to known how I can deal with this assert? Is it possible to avoid it by a code organisation? Is it possible to comment this assert?

 

To have a concrete answer, I have joined my complete VC++7.1 project.

 

Thanks in advance for your help.

 

Development Platform

WindowsXP

VC++ 7.1

Boost 1.33.1

 

Marc Viala

[hidden email]

 

 

 


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [boost][serialization] How to implementserializationclasses in two DLLs

Marc VIALA

Robert wrote:

> Truth is I havn't gotten to it.  Sorry.  Its a very tricky area.  One thing

> you might want to look at is the test which shows separate compilation.

> This avoids having the "same" code in both the executable and the dll which

> might help.

>

> Robert Ramey

 

 

Hi Robert,

 

Maybe you’ve missed my previous reply, see @ Thu, 2 Feb 2006. So I re-post it

 

Thanks to handle my request; I’ve looked the source directory “test” and “examples” of boost::serialization ver#1.33.1 and I didn’t find the test that you’ve pointed in your reply.

 

What’s the name of the test demonstrating separate compilation?

Do you have tested my source code sends with my previous post?

 

Marc Viala

[hidden email]

 

   _____ 

 

#include <LibA/A.h>

#include <LibB/B.h>

 

#include <boost/filesystem/path.hpp>

#include <boost/filesystem/fstream.hpp>

 

#pragma comment(lib, "liba_d.lib")

#pragma comment(lib, "libb_d.lib")

 

int

main(int argc, char* argv[])

{

  libA::A a;

  libA::save(&a, boost::filesystem::ofstream("a.xml"));

 

  libB::B b;

  libB::save(&b, boost::filesystem::ofstream("b.xml")); // -> Assert in debug mode

 

  return 0;

}

----------------------

 

The figure hereafter describes the relationships between LibA, LibB and EXE application:

                      ------------                              ------------

                      |       LibA      |                              |       LibB       |

                      ------------                               ------------

                                             \                          /

                                               \                       /                                                      

                                                  Exe Application

 

We have to face to an assert in debug mode generate by the file boost::serialization::extended_type_info.cpp, line#71. This assert happens during the instance serialization of class libB:B.

 

Recently, there are some posts on this subject, but I would like to known how I can deal with this assert? Is it possible to avoid it by a code organisation? Is it possible to comment this assert?

 

To have a concrete answer, I have joined my complete VC++7.1 project.

 

Thanks in advance for your help.

 

Development Platform

WindowsXP

VC++ 7.1

Boost 1.33.1

 

 

 

 


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users