title: Why am I getting "Undefined symbols ... typeinfo ... vtable" with a virtual and concrete class?
body: <p>I'm relearning C++ (meaning: go gentle on me! :).  I have a superclass (<code>Node</code>) with an abstract method (<code>step()</code>) that must be implemented in a subclass (<code>TestNode</code>).  It compiles without error and without any warnings, but linking it results in:</p>
  
  <pre><code>bash-3.2$ g++ -Wall -o ./bin/t1 src/t1.cpp
  Undefined symbols for architecture x86_64:
    "typeinfo for test::Node", referenced from:
        typeinfo for test::TestNode in t1-9f6e93.o
    "vtable for test::Node", referenced from:
        test::Node::Node() in t1-9f6e93.o
    NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>As far as I can tell, I <em>have</em> defined the "first non-inline virtual member function" (i.e. <code>TestNode::step()</code>).  </p>
  
  <p>I've read the error message carefully, I've read blog posts <a href="http://www.educatedguesswork.org/2011/09/undefined_symbol_vtable_what_t.html" rel="nofollow noreferrer">here</a> and have looked a number of other SO posts (<a href="https://stackoverflow.com/q/1693634/558639">Undefined symbols &quot;vtable for ...&quot; and &quot;typeinfo for...&quot;?</a>, <a href="https://stackoverflow.com/q/3658072/558639">How to find undefined virtual functions of a classes</a>, and <a href="https://stackoverflow.com/q/15265106/558639">c++ a missing vtable error</a>), but I feel no closer to enlightenment.</p>
  
  <p>What am I missing?  </p>
  
  <p>Here's the program in its entirety.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  namespace test {
  
    class Node {
    public:
      virtual Node&amp; step(int count);
    };
  
    class TestNode : public Node { 
    public:
      TestNode();
      ~TestNode();
      TestNode&amp; step(int count);
    };
  
    TestNode::TestNode() { }
    TestNode::~TestNode() { }
    TestNode&amp; TestNode::step(int count) {
      printf("count = %d\n", count);
      return *this;
    }
  
  } // namespace test    
  
  int main() {
    return 0;
  }
  </code></pre>