title: g++ linker error--typeinfo, but not vtable
body: <p>I know the standard answer for a linker error about missing typeinfo usually also involves vtable and some virtual function that I forgot to actually define.</p>
  
  <p>I'm fairly certain that's not the situation this time.</p>
  
  <p>Here's the error:</p>
  
  <p>UI.o: In function <code>boost::shared_ptr&lt;Graphics::Widgets::WidgetSet&gt;::shared_ptr&lt;Graphics::Resource::GroupByState&gt;(boost::shared_ptr&lt;Graphics::Resource::GroupByState&gt; const&amp;, boost::detail::dynamic_cast_tag)':
  UI.cpp:(.text._ZN5boost10shared_ptrIN8Graphics7Widgets9WidgetSetEEC1INS1_8Resource12GroupByStateEEERKNS0_IT_EENS_6detail16dynamic_cast_tagE[boost::shared_ptr&lt;Graphics::Widgets::WidgetSet&gt;::shared_ptr&lt;Graphics::Resource::GroupByState&gt;(boost::shared_ptr&lt;Graphics::Resource::GroupByState&gt; const&amp;, boost::detail::dynamic_cast_tag)]+0x30): undefined reference to</code>typeinfo for Graphics::Widgets::WidgetSet'</p>
  
  <p>Running c++filt on the obnoxious mangled name shows that it actually is looking at .boost::shared_ptr::shared_ptr(boost::shared_ptr const&amp;, boost::detail::dynamic_cast_tag)</p>
  
  <p>The inheritance hierarchy looks something like</p>
  
  <pre><code>class AbstractGroup
  {
     public:
        virtual ~AbstractGroup();
        typedef boost::shared_ptr&lt;AbstractGroup&gt; Ptr;
        ...
  };
  
  class WidgetSet : public AbstractGroup
  {
      public:
         virtual ~WidgetSet();
         typedef boost::shared_ptr&lt;WidgetSet&gt; Ptr;
         ...
  };
  
  class GroupByState : public AbstractGroup
  {
      public:
         virtual ~GroupByState();
         ...
  };
  </code></pre>
  
  <p>Then there's this:</p>
  
  <pre><code>class UI : public GroupByState
  {
      public:
         virtual ~UI();
         ...
         void LoadWidgets( GroupByState::Ptr resource );
         ...
  };
  </code></pre>
  
  <p>Then the original implementation:</p>
  
  <pre><code>void UI::LoadWidgets( GroupByState::Ptr resource )
  {
     WidgetSet::Ptr tmp( boost::dynamic_pointer_cast&lt; WidgetSet &gt;(resource) );
     if( tmp )
     {
         ...
     }
  }
  </code></pre>
  
  <p>Stupid error on my part (trying to cast to a sibling class with a shared parent), even if the error is kind of cryptic.</p>
  
  <p>Changing to this:</p>
  
  <pre><code>void UI::LoadWidgets( AbstractGroup::Ptr resource )
  {
     WidgetSet::Ptr tmp( boost::dynamic_pointer_cast&lt; WidgetSet &gt;(resource) );
     if( tmp )
     {
         ...
     }
  }
  </code></pre>
  
  <p>(which I'm fairly sure is what I actually meant to be doing) left me with a very similar error:</p>
  
  <p>UI.o: In function <code>boost::shared_ptr&lt;Graphics::Widgets::WidgetSet&gt;::shared_ptr&lt;Graphics::_Drawer::Group&gt;(boost::shared_ptr&lt;Graphics::_Drawer::Group&gt; const&amp;, boost::detail::dynamic_cast_tag)':
  UI.cpp:(.text._ZN5boost10shared_ptrIN8Graphics7Widgets9WidgetSetEEC1INS1_7_Drawer5GroupEEERKNS0_IT_EENS_6detail16dynamic_cast_tagE[boost::shared_ptr&lt;Graphics::Widgets::WidgetSet&gt;::shared_ptr&lt;Graphics::_Drawer::Group&gt;(boost::shared_ptr&lt;Graphics::_Drawer::Group&gt; const&amp;, boost::detail::dynamic_cast_tag)]+0x30): undefined reference to</code>typeinfo for Graphics::Widgets::WidgetSet'
  collect2: ld returned 1 exit status</p>
  
  <p>dynamic_cast_tag is just an empty struct in boost/shared_ptr.hpp.  It's just a guess that boost might have anything at all to do with the error.</p>
  
  <p>Passing in a WidgetSet::Ptr totally eliminates the need for a cast, and it builds fine (which is why I think there's more going on than the standard answer for this question).</p>
  
  <p>Obviously, I'm trimming away a lot of details that might be important.  My next step is to cut it down to the smallest example that fails to build, but I figured I'd try the lazy way out and take a stab on here first.</p>
  
  <p>TIA!</p>
  
  <p>EDIT:  Show some more details that people have commented about</p>