Boost C++ Libraries: Ticket #6899: boost serialization calls wrong guild() https://svn.boost.org/trac10/ticket/6899 <p> I have a serializaiton program that serializes over 600 classes. During the singleton initialization, the program should call the guid() function defined in macro BOOST_CLASS_EXPORT_GUID in export.hpp. But about 40% of class singletons call the dummy guild() function defined in extened_type_info.hpp: </p> <p> template&lt;class T&gt;<br /> struct guid_defined : boost::mpl::false_ {};<br /> template&lt;class T&gt;<br /> inline const char * guid(){<br /> return NULL;<br />} </p> <p> This causes m_key=NULL, and later causes "unregistered class" error for multiple inheritence classes. </p> <p> The following two lines are ajacent in the same file. The first calls the dummy guid(), the second calls the macro guid().<br /> BOOST_CLASS_EXPORT_GUID(CffCDOQuote, "CffCDOQuote")<br /> BOOST_CLASS_EXPORT_GUID(boost::shared_ptr&lt; CffCDOQuote &gt;, "CffCDOQuotePtr") </p> <p> I am working in Windows 7, VC++ 9.0 and Boost 1.44.0. </p> <p> I tried all possible project settings of optimization and runtime, got no luck. </p> <p> It is difficult to create a simple test case. I will be happy to provide more info if needed. </p> <p> Thanks </p> <p> Xiaolong </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6899 Trac 1.4.3 Robert Ramey Sun, 15 Jul 2012 20:16:23 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6899#comment:1 https://svn.boost.org/trac10/ticket/6899#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> it looks that perhaps the serialization code for the derived classes are not getting explicitly instantiated. </p> <p> Check the documentation for BOOST_CLASS_EXPORT_KEY and BOOST_CLASS_EXPORT_IMPL. </p> <p> Also look at the test_dll_exported, test_dll_plugin and test_dll_simple. </p> <p> Also look at demo_polymorphic and maybe demo_pimpl. </p> <p> I think I'm right about this so I'm going to close this item for now. </p> <p> Robert Ramey </p> Ticket Xiaolong <xwu622@…> Wed, 18 Jul 2012 14:46:37 GMT <link>https://svn.boost.org/trac10/ticket/6899#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6899#comment:2</guid> <description> <p> Here are more details about this issue. I have 6 analytic libraries. I create a static library of boost-serialization wrapper for each of them. Then I link the 6 static serialization libraries into a dynamic library. </p> <p> I cannot use dynamic wrapper, because there would be one copy of singleton&lt;detail::ktmap&gt; in each wrapper. </p> <p> I found a workaround: linking directly to the .obj files, instead of linking to the 6 static library wrappers, when link the dynamic library. </p> <p> In summary: the class hierarchy tree map cannot across dll boundary. That makes it difficult to use boost-serialization to large scale projects. </p> <p> Having to link all serialization code into a single dll also caused errors like "file size exceeded 1G limit" (on linux), "the number of symbols exceeded 65535 limit" (on Windows). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 18 Jul 2012 16:38:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6899#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6899#comment:3</guid> <description> <p> "I have 6 analytic libraries. I create a static library of boost-serialization wrapper for each of them. Then I link the 6 static serialization libraries into a dynamic library." </p> <p> This is known to be a risky operation. Each static library will include static functions from the C runtime library which will be included in the dynamic library when it is made. If the main program is linked dynamically with the c runtime library, there will be different versions for the same code in the DLLS and the main line. This will violate the ODR. The problem is compounded when the main line is built with older DLLS. I would recommend the following: </p> <p> Build all the DLLS with the dynamic version of the C Runtime library and other tools like the serialization library. </p> <p> Build the Mainline with dynamic linking of libraries. </p> <p> This will gain you the following advantages: </p> <p> a) Only ONE version of every routine in your code - eliminates confusion and potential for weird untraceable errors. b) With a little bit of work, you can load the DLLS "on demand" so they don't even get loaded when the main line doesn't use them. This is very, very useful for polymorphic types. An example is that one could have a complex mainline application which uses serialization library archives - but only through the polymorphic interfaces. When you use a new/updated archive/serialization code, it can be used without even re-compiling the mainline! c) The code body to be shipped to the customer is smaller as it has no redundancies. </p> <p> and a disadvantage </p> <p> a) you have to ship the MS C runtime DLL along with your product. </p> <p> So, try building everything for dynamic linking and see if it helps. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> </channel> </rss>