Hi,<br><br>I want to use a non inline serialize method of a class. When<br>instantiating it not explicitly the linker quits with undefined symbols.<br>So I tried to instantiate it that way and it does not work anyway.<br>Here is my code. Does anyone see what I've done wrong?
<br>I did also try to use export.hpp but it doesn't help too.<br>Thank you very much, Jan.<br><br>// Class.hpp<br><br>#include &lt;boost/archive/xml_oarchive<div>.hpp&gt;<br>#include &lt;boost/archive/xml_iarchive.hpp&gt;
<br>#include &lt;boost/serialization/string.hpp&gt;
<br>#include &lt;boost/serialization/base_object.hpp&gt;<br>#include &lt;boost/serialization/utility.hpp&gt;<br><br>class CSerTest<br>{<br>&nbsp;&nbsp;&nbsp; std::string a_, b_, c_;<br>&nbsp;&nbsp;&nbsp; friend class boost::serialization::access;<br>


&nbsp;&nbsp;&nbsp; template&lt;class Archive&gt;&nbsp;&nbsp;&nbsp; void serialize( Archive &amp; ar, const unsigned int );
<br><br>&nbsp;&nbsp;&nbsp; public:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSerTest();<br>};<br><br>BOOST_CLASS_VERSION(CSerTest, 1);<br><br>// Class.cpp<br><br>#include &quot;Class.hpp&quot;<br><br>CSerTest::CSerTest() : a_(&quot;1&quot;), b_(&quot;2&quot;), c_(&quot;3&quot;)
<br>{<br><br>}<br><br>template&lt;class Archive&gt;&nbsp;&nbsp;&nbsp; void CSerTest::serialize( Archive &amp; ar, const unsigned int )<br>{<br>&nbsp;&nbsp;&nbsp; ar &amp; BOOST_SERIALIZATION_NVP(a_) &amp; BOOST_SERIALIZATION_NVP(b_) &amp; BOOST_SERIALIZATION_NVP(c_);
<br>}<br><br>// main.cpp<br><br>#include &lt;fstream&gt;<br>#include &quot;Class.hpp&quot;<br><br>///////////////////////// without effect ////////////////////////////////////<br>template void CSerTest::serialize&lt;boost::archive::xml_oarchive&gt;(boost::archive::xml_oarchive&amp;, unsigned int );
<br><br>int main()<br>{<br>&nbsp;&nbsp;&nbsp; CSerTest instance;<br><br>&nbsp;&nbsp;&nbsp; std::ofstream ofs( &quot;out_file.txt&quot; );<br>&nbsp;&nbsp;&nbsp; boost::archive::xml_oarchive oxa( ofs );<br>&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp; oxa &lt;&lt; BOOST_SERIALIZATION_NVP(instance);<br>



}<br><br>The linker (MS version 8) returns with:<br>---<br>Creating library mytest.lib and object mytest.exp<br>Main.obj : error LNK2019: unresolved external symbol &quot;private: void<br>__thiscall CSerTest::serialize&lt;class boost::archive::xml_oarchive&gt;(class
boost::archive::xml_oarchive &amp;,unsigned int)&quot;(??$serialize@
Vxml_oarchive@archive@boost@@@CSerTest@@AAEXAAVxml_oarchive@archive@boost@@I@Z)
referenced in function &quot;public: static void __cdeclboost::serialization::access::serialize&lt;class boost::archive::xml_oarchive,class CSerTest&gt;(class boost::archive::xml_oarchive &amp;,class CSerTest &amp;,unsigned int)&quot;(??$serialize@
Vxml_oarchive@archive@boost@@VCSerTest@@@access@serialization@boost@@SAXAAVxml_oarchive@archive@2@AAVCSerTest@@I@Z)mytest.exe<br>: fatal error LNK1120: 1 unresolved externals</div>