title: collect2: Ld returned 1 exit status build make error
body: <p>Compiler: Qt
  Language: C++</p>
  
  <p>This program is just not for me haha, this is the third time I've had to ask for help, and it's driving me crazy (thank you everyone for being so patient and helpful with me)</p>
  
  <p>I tried running my program (again for the millionth time) Since I can't get the ostream sorted out, I commented out all the cout functions in my main so I could deal with the rest of my code. But when I try to run it I get collect2: ld returned 1 exit status in my build issues.</p>
  
  <p>I switched to Compile Output... and gosh..</p>
  
  <blockquote>
    <p>Running build steps for project List...
    Configuration unchanged, skipping qmake step.
    Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `C:/Qt/2010.05/bin/List-build-desktop'</p>
    
    <p>C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug</p>
    
    <p>mingw32-make[1]: Entering directory
    `C:/Qt/2010.05/bin/List-build-desktop'</p>
    
    <p>g++ -enable-stdcall-fixup -Wl,-enable-auto-import
    -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\List.exe debug/main.o debug/list.o  -L"c:\Qt\2010.05\qt\lib" -lQtCored4 </p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:194:
    undefined reference to `List::getNewNode(double const&amp;)'</p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:215:
    undefined reference to `List::getNewNode(double const&amp;)'</p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:215:
    undefined reference to `List::getNewNode(int const&amp;)'</p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:194:
    undefined reference to `List::getNewNode(int const&amp;)'</p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:466:
    undefined reference to `List::getNewNode(int const&amp;)'</p>
    
    <p>debug/main.o:C:\Qt\2010.05\bin\List-build-desktop/../List//List.h:466:
    undefined reference to `List::getNewNode(double const&amp;)'</p>
    
    <p>collect2: ld returned 1 exit status</p>
    
    <p>mingw32-make[1]: Leaving directory
    `C:/Qt/2010.05/bin/List-build-desktop'</p>
    
    <p>mingw32-make: Leaving directory `C:/Qt/2010.05/bin/List-build-desktop'</p>
    
    <p>mingw32-make[1]: <em>*</em> [debug\List.exe] Error 1</p>
    
    <p>mingw32-make: <em>*</em> [debug] Error 2</p>
    
    <p>The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with
    code %2. Error while building project List (target: Desktop) When
    executing build step 'Make'</p>
  </blockquote>
  
  <p>That's basically what I got. I have 2 header files and one source file. 
  Headers: ListNode.h and list.h and my cpp is main.cpp</p>
  
  <p>everything links to each other, so i don't understand why it's giving me undefined reference errors. </p>
  
  <p>All my other friends have pretty much given up on this assignment, and I refuse to give up. I just won't go to bed tonight ha. Thanks again for the help!</p>
  
  <p>EDIT::-- CODE</p>
  
  <p>ListNode.h</p>
  
  <pre><code>#ifndef LISTNODE_H
  #define LISTNODE_H
  
  template&lt;typename NODETYPE&gt; class List;
  
  template&lt;typename NODETYPE&gt;
  class ListNode
  {
      friend class List&lt; NODETYPE &gt;;
  
  public:
      ListNode(const NODETYPE &amp;);
      NODETYPE getData() const;
  private:
      NODETYPE data;
      ListNode&lt; NODETYPE &gt; *nextPtr;
  
  };
  
  template&lt;typename NODETYPE&gt;
  ListNode&lt; NODETYPE &gt;::ListNode(const NODETYPE &amp;info)
      :data(info), nextPtr(0)
  {
  
  }
  
  template&lt;typename NODETYPE&gt;
  NODETYPE ListNode&lt; NODETYPE &gt;::getData() const
  {
      return data;
  }
  
  
  #endif // LISTNODE_H
  </code></pre>
  
  <p>I won't put everything, because it's a lot... this is the List.h..I can only imagine how much of it is still wrong, but I can't check because the error...</p>
  
  <pre><code>#include &lt;iostream&gt;
  using std::cout;
  
  #include &lt;fstream&gt;
  
  #include &lt;string&gt;
  using std::ostream;
  
  #include "ListNode.h"
  
  template&lt; typename NODETYPE &gt;
  class List
  {
    //template &lt;typename OUTPUT &gt;
    //friend ostream &amp;operator &lt;&lt;(ostream &amp;, const List&lt;NODETYPE&gt; &amp; );
  
  public:
      List();
      ~List();
      void insertAtFront( const NODETYPE &amp; );
      void insertAtBack( const NODETYPE &amp; );
      bool removeFromFront( NODETYPE &amp; );
      bool removeFromBack( NODETYPE &amp; );
      bool isEmpty() const;
      void print() const;
  
  
      bool append(const NODETYPE &amp;);
      bool add_n(int, const NODETYPE &amp;);
      bool concat(List&amp;);
      void reverse();
      bool remove_last();
      bool remove_n(int);
      void sort();
      bool merge(List&amp;);
      void add_in(const NODETYPE &amp;);
      void remove(const NODETYPE &amp;);
      NODETYPE sum();
      int count();
  
  private:
      ListNode&lt; NODETYPE &gt; *firstPtr;
      ListNode&lt; NODETYPE &gt; *lastPtr;
  
      ListNode&lt; NODETYPE &gt; *getNewNode( const NODETYPE &amp;);
  
  };
  
  template&lt;typename NODETYPE&gt;
  List&lt;NODETYPE&gt;::List()
      : firstPtr(0), lastPtr(0)
  {
  
  }
  
  template&lt; typename NODETYPE&gt;
  List&lt;NODETYPE&gt;::~List()
  {
      if( !isEmpty() )
      {
          cout &lt;&lt; "Destroying Nodes...\n";
  
          ListNode&lt; NODETYPE &gt; *currentPtr = firstPtr;
          ListNode&lt; NODETYPE &gt; *tempPtr;
  
          while ( currentPtr != 0)
          {
              tempPtr = currentPtr;
              cout &lt;&lt; tempPtr-&gt;data &lt;&lt; "\n";
              currentPtr = currentPtr-&gt;nextPtr;
              delete tempPtr;
          }
      }
  
      cout &lt;&lt; "All nodes destroyed \n\n";
  }
  
  template&lt; typename NODETYPE &gt;
  void List&lt; NODETYPE&gt;::insertAtFront(const NODETYPE &amp;value)
  {
      ListNode&lt; NODETYPE &gt; *newPtr = getNewNode (value);
  
      if( isEmpty())
          firstPtr = lastPtr = newPtr;
      else
      {
          newPtr-&gt;nextPtr = firstPtr;
          firstPtr = newPtr;
      }
  }
  
  template&lt; typename NODETYPE &gt;
  void List&lt;NODETYPE&gt;::insertAtBack(const NODETYPE &amp;value)
  {
      ListNode&lt;NODETYPE&gt; *newPtr = getNewNode(value);
  
      if( isEmpty())
          firstPtr = lastPtr = newPtr;
      else
      {
          lastPtr-&gt;nextPtr = newPtr;
          lastPtr = newPtr;
      }
  }
  
  template&lt; typename NODETYPE &gt;
  bool List&lt;NODETYPE&gt;::removeFromFront(NODETYPE &amp;value)
  {
      if(isEmpty())
          return false;
      else
      {
          ListNode&lt;NODETYPE&gt; *tempPtr = firstPtr;
  
          if(firstPtr == lastPtr)
              firstPtr = lastPtr = 0;
          else
              firstPtr = firstPtr-&gt;nextPtr;
  
          value = tempPtr-&gt;data;
          delete tempPtr;
          return true;
      }
  }
  
  template&lt;typename NODETYPE&gt;
  bool List&lt;NODETYPE&gt;::removeFromBack(NODETYPE &amp;value)
  {
      if( isEmpty())
          return false;
      else
      {
          ListNode&lt;NODETYPE&gt; *tempPtr = lastPtr;
  
          if(firstPtr == lastPtr)
              firstPtr = lastPtr = 0;
          else
          {
              ListNode&lt;NODETYPE&gt; *currentPtr = firstPtr;
  
              while (currentPtr-&gt;nextPtr != lastPtr)
                  currentPtr = currentPtr-&gt;nextPtr;
  
              lastPtr=currentPtr;
              currentPtr-&gt;nextPtr = 0;
          }
          value = tempPtr-&gt;data;
          delete tempPtr;
          return true;
      }
  }
  
  template&lt;typename NODETYPE&gt;
  bool List&lt;NODETYPE&gt;::isEmpty() const
  {
      return firstPtr == 0;
  }
  
  template&lt;typename NODETYPE&gt;
  void List&lt;NODETYPE&gt;::print() const
  {
      if( isEmpty())
      {
          cout&lt;&lt;"The list is empty \n\n";
          return;
      }
      ListNode&lt;NODETYPE&gt; *currentPtr = firstPtr;
  
      cout&lt;&lt; "The list is: ";
  
      while(currentPtr != 0)
      {
          cout&lt;&lt;currentPtr-&gt;data&gt;&gt; ' ';
          currentPtr = currentPtr-&gt;nextPtr;
      }
  
      cout&lt;&lt; "\n\n";
  }
  
  /*template&lt;typename NODETYPE&gt;
  ostream &amp;operator &lt;&lt;(ostream &amp;output, const List&lt;NODETYPE&gt;&amp; value)
  {
      output &lt;&lt; value;
      return output;
  }*/
  
  
  template&lt;typename NODETYPE&gt;
  bool List&lt;NODETYPE&gt;::append(const NODETYPE &amp;value)
  {
      ListNode&lt;NODETYPE&gt; *newPtr = getNewNode(value);
  
     if(isEmpty())
     {
          firstPtr = lastPtr = newPtr;
          return true;
      }
      else
      {
          ListNode&lt;NODETYPE&gt; *tempPtr = lastPtr;
  
          tempPtr-&gt;nextPtr=newPtr;
          lastPtr = newPtr;
          return true;
      }
  
  }
  
  template&lt;typename NODETYPE&gt;
  bool List&lt;NODETYPE&gt;::add_n(int a, const NODETYPE &amp;value)
  {
      ListNode&lt;NODETYPE&gt; *newPtr = getNewNode(value);
  
      if(isEmpty())
      {
          firstPtr = lastPtr = newPtr;
          return true;
      }
      if(a &lt;= count())
      {
          lastPtr-&gt;nextPtr = newPtr;
          lastPtr = newPtr;
          return true;
      }
      else
      {
          ListNode&lt;NODETYPE&gt; *currentPtr = firstPtr;
          for(int cntr = 1; cntr &lt; count(); cntr++)
          {
              if(cntr == a)
              {
                  newPtr-&gt;nextPtr = currentPtr-&gt;nextPtr;
                  currentPtr-&gt;nextPtr = newPtr;
                  return true;
              }
  
              currentPtr = currentPtr-&gt;nextPtr;
          }
          return false;
      }
  }
  
  template&lt;typename NODETYPE&gt;
  bool List&lt;NODETYPE&gt;::concat(List&lt;NODETYPE&gt; &amp;li)
  {
      if(isEmpty())
          return false;
      if(li.isEmpty())
          return false;
      else
      {
          ListNode&lt;NODETYPE&gt; *tempPtr = lastPtr;
  
          tempPtr-&gt;nextPtr = li.firstPtr;
          tempPtr = tempPtr-&gt;nextPtr;
  
          while(tempPtr-&gt;nextPtr != 0)
              tempPtr = tempPtr-&gt;nextPtr;
  
          lastPtr = tempPtr;
  
          return true;
  
      }
  
  }
  
  template&lt;typename NODETYPE&gt;
  void List&lt;NODETYPE&gt;::reverse()
  {
      if(isEmpty())
          return;
      else
      {
         int chk = count();
         ListNode&lt;NODETYPE&gt; *currentPtr = firstPtr-&gt;nextPtr;
         ListNode&lt;NODETYPE&gt; *tempPtr = firstPtr;
         ListNode&lt;NODETYPE&gt; *tempPtr2;
  
         for(int a = 1; a &lt; chk; a++)
         {
             tempPtr2 = currentPtr-&gt;nextPtr;
             tempPtr-&gt;nextPtr = currentPtr-&gt;nextPtr;
             currentPtr-&gt;nextPtr = firstPtr;
             firstPtr = currentPtr;
             currentPtr = tempPtr2;
  
         }
  
         lastPtr = tempPtr;
      }
  }
  </code></pre>
  
  <p>main.cpp </p>
  
  <pre><code>#include "List.h"
  
  #include &lt;iostream&gt;
  using std::cout;
  using std::endl;
  
  
  int main()
  {
    List&lt;int&gt; Li, Li2, Li3;
    List&lt;double&gt; Ld, Ld2;
  
    Ld.append(11.1);
    Ld.append(22.2);
    Ld.append(33.3);
    Ld.add_n(35.5,2);
    //cout &lt;&lt; "Ld is: " &lt;&lt; Ld &lt;&lt; endl;
  
    Ld.reverse();
    //cout &lt;&lt; "Ld is: " &lt;&lt; Ld &lt;&lt; endl;
  
    Li.add_n(15,-1);
    Li.add_n(16,0);
    Li.add_n(17,1);
    Li.append(10);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
  
    Li2.append(5);
    Li2.append(6);
    Li2.add_n(7,2);
    Li2.add_n(8,1);
    //cout &lt;&lt; "Li2 is: " &lt;&lt; Li2 &lt;&lt; endl;
  
    // You shouldn't use Li2 after the concatenation, because the
    // elements aren't copied, just connected to form one list.
  
    Li.concat(Li2);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
    //cout &lt;&lt; "Li2 is: " &lt;&lt; Li2 &lt;&lt; endl;
  
    Li.sort();
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
  
    Li3.append(20);
    Li3.append(10);
    Li3.add_n(50,1);
    Li3.add_n(40,3);
    //cout &lt;&lt; "Li3 is: " &lt;&lt; Li3 &lt;&lt; endl;
  
    Li.merge(Li3);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
    //cout &lt;&lt; "Li3 is: " &lt;&lt; Li3 &lt;&lt; endl;
  
    Li3.sort();
    //cout &lt;&lt; "Li3 is: " &lt;&lt; Li3 &lt;&lt; endl;
  
    // Li3 should not be used after the merge, since the nodes have been removed.
  
    Li.merge(Li3);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
  
    Li.add_in(25);
    Li.add_in(4);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
  
    Li.remove(10);
    Li.remove(50);
    //cout &lt;&lt; "Li is: " &lt;&lt; Li &lt;&lt; endl;
  
    Ld.add_in(14.3);
    Ld.remove(14.3);
    //cout &lt;&lt; "Ld is: " &lt;&lt; Ld &lt;&lt; endl;
  
    Ld2 = Ld;
    //cout &lt;&lt; "Ld is: " &lt;&lt; Ld &lt;&lt; endl;
    //cout &lt;&lt; "Ld2 is: " &lt;&lt; Ld2 &lt;&lt; endl;
  
    Ld.sort();
    //cout &lt;&lt; "Ld is: " &lt;&lt; Ld &lt;&lt; endl;
    //cout &lt;&lt; "Ld2 is: " &lt;&lt; Ld2 &lt;&lt; endl;
  
    cout &lt;&lt; "Li has " &lt;&lt; Li.count() &lt;&lt; " nodes with a total value of "
        &lt;&lt; Li.sum() &lt;&lt; endl;
  
    cout &lt;&lt; "Ld has " &lt;&lt; Ld.count() &lt;&lt; " nodes with a total value of "
         &lt;&lt; Ld.sum() &lt;&lt; endl;
  
  
    return 0;
  }
  </code></pre>
  
  <p>.pro file as requested</p>
  
  <pre><code>#-------------------------------------------------
  #
  # Project created by QtCreator 2012-09-20T02:33:43
  #
  #-------------------------------------------------
  
  QT       += core
  
  QT       -= gui
  
  TARGET = List
  CONFIG   += console
  CONFIG   -= app_bundle
  
  TEMPLATE = app
  
  
  SOURCES += main.cpp \
      list.cpp
  
  HEADERS += \
      list.h \
      ListNode.h
  </code></pre>