
Hi, I want to use a non inline serialize method of a class. When instantiating it not explicitly the linker quits with undefined symbols. So I tried to instantiate it that way and it does not work anyway. Here is my code. Does anyone see what I've done wrong? I did also try to use export.hpp but it doesn't help too. Thank you very much, Jan. // Class.hpp #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/serialization/string.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/utility.hpp> class CSerTest { std::string a_, b_, c_; friend class boost::serialization::access; template<class Archive> void serialize( Archive & ar, const unsigned int ); public: CSerTest(); }; BOOST_CLASS_VERSION(CSerTest, 1); // Class.cpp #include "Class.hpp" CSerTest::CSerTest() : a_("1"), b_("2"), c_("3") { } template<class Archive> void CSerTest::serialize( Archive & ar, const unsigned int ) { ar & BOOST_SERIALIZATION_NVP(a_) & BOOST_SERIALIZATION_NVP(b_) & BOOST_SERIALIZATION_NVP(c_); } // main.cpp #include <fstream> #include "Class.hpp" ///////////////////////// without effect //////////////////////////////////// template void CSerTest::serialize<boost::archive::xml_oarchive>(boost::archive::xml_oarchive&, unsigned int ); int main() { CSerTest instance; std::ofstream ofs( "out_file.txt" ); boost::archive::xml_oarchive oxa( ofs ); oxa << BOOST_SERIALIZATION_NVP(instance); } The linker (MS version 8) returns with: --- Creating library mytest.lib and object mytest.exp Main.obj : error LNK2019: unresolved external symbol "private: void __thiscall CSerTest::serialize<class boost::archive::xml_oarchive>(class boost::archive::xml_oarchive &,unsigned int)"(??$serialize@ Vxml_oarchive@archive@boost@@@CSerTest@@AAEXAAVxml_oarchive@archive@boost@@ I@Z) referenced in function "public: static void __cdeclboost::serialization::access::serialize<class boost::archive::xml_oarchive,class CSerTest>(class boost::archive::xml_oarchive &,class CSerTest &,unsigned int)"(??$serialize@ Vxml_oarchive@archive@boost@@VCSerTest@@@access@serialization@boost@@ SAXAAVxml_oarchive@archive@2@AAVCSerTest@@I@Z)mytest.exe : fatal error LNK1120: 1 unresolved externals