title: Boost serialization unregistered class errors
body: <p>I cannot seem to get boost::serialization to work well. I have sprinkled the class .cpp files with <code>BOOST_CLASS_EXPORT_GUID</code> macros, after including the class and archive headers, but I still get <code>unregistered_class</code> exceptions.</p>
  
  <p>I have looked around and it seems that whatever I can find is 1. either outdated, dealing with old versions of the library, or 2. works only for a simple one-file solution in which all the serializable classes are defined one after the other. Nothing I've found helps.</p>
  
  <p>My solution at present consists of a project, compiled into a static library, that contains the core functionality with the basic archivable classes, and another test project that will eventually be fleshed out into a more concrete logic layer. Getting everything to work with boost::serialization is proving a nightmare. I'm almost tempted to write it myself.</p>
  
  <p>Anyway, the class in question which raises the exception is defined in a header, which looks something like this:</p>
  
  <pre><code>#include &lt;boost/serialization/assume_abstract.hpp&gt;
  #include &lt;boost/serialization/serialization.hpp&gt;
  // Other includes...
  
  namespace GameCore { class Component; }
  //  Forward declare some boost::serialization functions that appear at the bottom.
  // ...
  BOOST_SERIALIZATION_ASSUME_ABSTRACT(GameCore::Component);
  
  namespace GameCore
  {
      // Some forward declares..
  
  //////////////////////////////////////////////////////////////////////////
  //  Base component type.
  //////////////////////////////////////////////////////////////////////////
  class Component : public Updatable, public Object
  {
      friend class boost::serialization::access;  
  
  protected:                                  
      template &lt;typename Archive&gt;                 
      friend void boost::serialization::serialize(Archive&amp; archive, Component&amp; object, const unsigned int version);   
      template &lt;typename Archive&gt; friend void boost::serialization::load_construct_data(Archive&amp; archive, Component* t, const unsigned int version);  
      template &lt;typename Archive&gt; friend void boost::serialization::save_construct_data(Archive&amp; archive, const Component* t, const unsigned int version);    
  
  public:
      Component(GameObject&amp; owner);
      virtual ~Component() = 0;
  
      // Irrelevant stuff..
  
      GameObject&amp; gameObject;
      Transform* transform;
  };
  }
  //  The component includes have to be placed here because it would otherwise create a cyclic inclusion when trying to compile the 
  //  individual component classes, say, Transform, which would end up including itself.
  #include "Transform.h"
  
  
  namespace boost
  {
      namespace serialization
      {
          template&lt;class Archive&gt;
          inline void save_construct_data(Archive&amp; archive, const GameCore::Component* t, const unsigned int version)
          {
              archive &lt;&lt; t-&gt;gameObject;
          }
  
  
      template&lt;class Archive&gt;
      inline void load_construct_data(Archive&amp; archive, GameCore::Component* t, const unsigned int version)
      {
          //  Retrieve data from archive required to construct new instance.
          GameCore::GameObject owner;
          archive &gt;&gt; owner;
  
          //  Invoke inplace constructor to initialize instance of class.
          ::new(t)GameCore::Component(owner);
      }
  
  
      //////////////////////////////////////////////////////////////////////////
      //  Serialization function for save/load.
      //////////////////////////////////////////////////////////////////////////
      template &lt;typename Archive&gt;
      void serialize(Archive&amp; archive, GameCore::Component&amp; t, const unsigned int version)
      {
          archive &amp; boost::serialization::base_object&lt;GameCore::Object&gt;(t);
          archive &amp; boost::serialization::base_object&lt;GameCore::Updatable&gt;(t);
          archive &amp; t.gameObject;
          archive &amp; t.transform;
      }
  }
  }
  </code></pre>
  
  <p>That is <strong>one</strong> header file. Sorry for the verbosity. Its .cpp file starts like this:</p>
  
  <pre><code>#include "Component.h"
  
  #include &lt;boost/serialization/export.hpp&gt;
  #include &lt;boost/archive/text_iarchive.hpp&gt;
  #include &lt;boost/archive/text_oarchive.hpp&gt;
  // Other includes...
  
  BOOST_CLASS_EXPORT_GUID(GameCore::Component, "GameCore::Component");
  
  // Class method definitions here.
  </code></pre>
  
  <p>The exception is raised when I try to archive an instance object that <strong>derives</strong> from <code>Component</code>, which itself is an abstract class. I'm archiving through a simple method defined in a different manager class:</p>
  
  <pre><code>std::ofstream outputFile(fileName);
  boost::archive::text_oarchive outputArchive(outputFile);
  outputArchive &lt;&lt; objects;
  </code></pre>
  
  <p>where <code>objects</code> is a <code>std::list</code> of <code>Object</code>s. <code>Object</code> is the base class from which all things, including <code>Component</code>s, derive. </p>
  
  <p>I apologize if this sounds convoluted, but there's only three layers of inheritance, and I believe I had a neat and effective architecture before thoughts of serialization crept in.</p>
  
  <p>If you could help me get rid of the irrational <code>unregistered_class</code> exceptions I'll light a candle for your souls!</p>
  
  <p><strong>Update:</strong> Funny thing is, the exception isn't raised for all derived classes of <code>Component</code>. </p>