title: ld: symbol(s) not found for architecture x86_64 [Eclipse, g++]
body: <p>I am trying to implement my own Doubly Linked List in C++ (yes, I know std already has one) and I keep getting the famous evil compiler error:</p>
  
  <p><code>ld: symbol(s) not found for architecture x86_64</code></p>
  
  <p>I know this is common, and I have had it happen many times before and resolved it, however I cannot seem to figure out why it is happening this time around. I have seen almost every SO thread on the topic, and none of them seem to correct it. </p>
  
  <p>I am using a class template, however all of my member functions are inline within the header file, and all declared functions are implemented. I am using The latest Eclipse on a Retina Macbook pro, compiling with clang.</p>
  
  <p>Please help!!!</p>
  
  <pre><code>/*
   * StackDLL.h
   */
  #ifndef STACKDLL_H_
  #define STACKDLL_H_
  #include &lt;iostream&gt;
  
  
  namespace std {
  
  template &lt;typename T&gt;
  class StackDLL {
          /* Node in the DLL */
          struct Node {
                  T data; // data held in node
                  Node* next;
                  Node* prev;
                  Node(T data);
                  Node(T data, Node* n, Node* p); // constructor
  
                  T getData(); // gets data
                  Node* getNext(); // gets node's next member
                  Node* getPrev(); // gets previous member
                  void setData(T data);
          }; // struct Node
  
      private:
          Node* head; // pointer to head of DLL
          Node* tail; // pointer to tail of DLL
          int size; // size of list
  
      public:
          StackDLL() {
              this-&gt;head = NULL;
              this-&gt;tail = NULL;
              this-&gt;size = 0;;
          }
          ~StackDLL() {
              while (head) {
                  Node* temp(head);
                  head=head-&gt;next;
                  delete temp;
              }
          }
  
  
          void add(T data); // adds new node to DLL holding data of type T
          void remove(); // removes current element from list
          bool empty() const;
          operator bool() const { return !empty(); } // checks if empty
  };
  
  
  template&lt;typename T&gt;
   StackDLL&lt;T&gt;::Node::Node(T data)
  {
      this-&gt;data = data;
      this-&gt;next = this-&gt;prev = NULL; // set next and previous pointers to NULL
  
  }
  
  template&lt;typename T&gt;
   StackDLL&lt;T&gt;::Node::Node(T data, Node* n, Node* p)
  {
      this-&gt;data = data;
      this-&gt;next = n;
      this-&gt;prev = p;
  }
  
  /*
   * Returns Data at node
   */
  template&lt;typename T&gt;
   T StackDLL&lt;T&gt;::Node::getData()
  {
      return this-&gt;data;
  }
  
  /*
   * returns next pointer of a given node
   */
  template&lt;typename T&gt;
  typename StackDLL&lt;T&gt;::Node* StackDLL&lt;T&gt;::Node::getNext()
  {
      return this-&gt;next;
  }
  
  /*
   * returns previous pointer of a given node
   */
  template&lt;typename T&gt;
  typename StackDLL&lt;T&gt;::Node* StackDLL&lt;T&gt;::Node::getPrev()
  {
      return this-&gt;prev;
  }
  
  /*
   * Sets data of a node
   */
  template&lt;typename T&gt;
   void StackDLL&lt;T&gt;::Node::setData(T data)
  {
      this-&gt;data = data;
  }
  
  /*
   * adds a new node holding data to the DLL
   */
  template&lt;typename T&gt;
   void StackDLL&lt;T&gt;::add(T data)
  {
      // create new node and make it tail
      Node* node = new Node(data);
  
  
      // If list is empty, both head/tail point to new element
      if ( this-&gt;empty() ) {
          this-&gt;head = node;
          this-&gt;tail = node;
          node-&gt;prev = NULL; // update previous to null
      }
  
      else {
          node-&gt;prev = tail; // if not empty, previous = tail
      }
  
      this-&gt;tail = node; // update DLL tail pointer
      this-&gt;size++; // increment size
  }
  
  
  /*
   * removes node from DLL
   */
  template&lt;typename T&gt;
   void StackDLL&lt;T&gt;::remove()
  {
      if (! empty() ) {
          tail = tail-&gt;prev; // previous element becomes new tail
          tail-&gt;next = NULL;
      }
  }
  
  /*
   * checks if DLL is empty
   */
  template&lt;typename T&gt;
   bool StackDLL&lt;T&gt;::empty() const
  {
      return ( !head || !tail );
  }
  
  } // namespace std
  
  
  #endif /* STACKDLL_H_ */
  </code></pre>
  
  <p>And here is the actual compiler error:</p>
  
  <pre><code>21:12:17 **** Incremental Build of configuration Debug for project project5 ****
  make all 
  Building target: project5
  Invoking: MacOS X C++ Linker
  g++  -o "project5"  ./DLLdriver.o ./StackDLL.o   
  Undefined symbols for architecture x86_64:
    "_main", referenced from:
       implicit entry/start for main executable
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [project5] Error 1
  
  21:12:17 Build Finished (took 61ms)
  </code></pre>