
Hello all, I am new to the boost community and libraries and need some help. I am taking over a small project which uses boost serialization. We are having trouble using the BOOST_CLASS_EXPORT macro with version 1.39. We are in the process of upgrading to v1.47, but have not yet complete the transition on our other supporting DLLs. My question is this: When we include the macro in our CPP file, it builds ok and appears to be ready to rock, however when we attempt to serialze the object, an exception is thrown. after stepping deeply, we see that the derived class load_construct_data and save_construct_data methods are not getting called. We have followed the documentation and it appears we have it implemented properly. Shown here are code snippets of what we are doing... When the macro use was in the HPP files, the serialization worked, but then an exception was thrown when the application ends. Either way, there is an issue. From what I can tell in boost docs, the macro use needs to be in the CPP and not in the HPP If anyone can give assistance that would be great. I am so new to Boost that I'm not sure I am using the right nomanclature to describe what is occuring. Any help that I can get will be much appreciated. Eric emaes@miengsrv.com // ************ derived class (Calculator) load/save definition ********* // template inline void save_construct_data (Archive& ar, const LpsTktMDO::Calculator* t, const unsigned int file_version) { // save data required to construct instance Lps::CharString name; Lps::CharString expression; name=t->getName (); expression=t->getExpression (); ar << boost::serialization::make_nvp ("name", name); ar << boost::serialization::make_nvp ("expression", expression); } //! //! Serialization method for loading a Calculator object //! //! \return None //! template inline void load_construct_data (Archive& ar, LpsTktMDO::Calculator* t, const unsigned int file_version) { // retrieve data from archive required to construct new instance Lps::CharString name; Lps::CharString expression; ar >> boost::serialization::make_nvp ("name", name); ar >> boost::serialization::make_nvp ("expression", expression); // invoke inplace constructor to initialize instance of my_class ::new(t)LpsTktMDO::Calculator (name, expression); } // ************ base class (Function) serialize definition ********* // template void serialize (Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP (theNameM); ar & BOOST_SERIALIZATION_NVP (thePmmIdM); ar & BOOST_SERIALIZATION_NVP (theDataMgrM); }; // ************ call to serialize the map of calculator/function objects (which is a member of a PreDef object) ********* // template void serialize (Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_NVP (theDesignVariablesM); // <<-------- this works ar & BOOST_SERIALIZATION_NVP (theVariablesM); // <<-------- this works ar & BOOST_SERIALIZATION_NVP (theFunctionsM); // <<-------- this call issues the exception! ar & BOOST_SERIALIZATION_NVP (theDataMgrM); // <<-------- this works }; // ************ call to serialize the PreDef object ********* // BOOST_CHECK_NO_THROW(theOa << BOOST_SERIALIZATION_NVP(thePreDefM)); -- View this message in context: http://boost.2283326.n4.nabble.com/BOOST-CLASS-EXPORT-in-C-tp3696005p3696005... Sent from the Boost - Dev mailing list archive at Nabble.com.

Eric Maes wrote:
If anyone can give assistance that would be great. I am so new to Boost that I'm not sure I am using the right nomanclature to describe what is occuring. Any help that I can get will be much appreciated.
Look at the most recent documentation. The problem if import/export declaration definition is a confusing and long standing. It came up littlle by little as boost serialization has crept into more and more ambitious projects involving DLLS. I believe it's definitively fixed now. (I always believe that). The solution is in the more recent library versions. It properly separates the concept of EXPORT declaration from implemenation. Robert Ramey

Robert, thank you for the reply. We are not quite able to move our supporting DLLs up to v1.47, but I think it will occur quick than expected now. We will try it and I will report back. In the meantime, if any else can give help regarding this with v1.39, it would be much appreciated. Eric -- View this message in context: http://boost.2283326.n4.nabble.com/BOOST-CLASS-EXPORT-in-C-tp3696005p3699126... Sent from the Boost - Dev mailing list archive at Nabble.com.
participants (2)
-
Eric Maes
-
Robert Ramey