title: C++ Linker Error ("Linker command failed with exit code 1")
body: <p>I'm working on a project and keep getting a linker error, even though there is essentially no executable code thus far. The error message is below, and from what I gather, it has to do with the overloaded assignment operator, which I have not defined yet. </p>
  
  <p>I can elaborate further through private messages, or if you would like to see the code. This is due to my school's academic integrity policy, and I do not wish to be expelled! </p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>Invoking: MacOS X C++ Linker</p>
  
  <p>g++  -o "ProjectName"  ./Class.o ./ProjectName.o<br>
  Undefined symbols for architecture x86_64:</p>
  
  <p>"Class::operator=(Class const&amp;)", referenced from:</p>
  
  <pre><code>  Class::Class(Class const&amp;) in Class.o
  </code></pre>
  
  <p>ld: symbol(s) not found for architecture x86_64</p>
  
  <p>clang: error: linker command failed with exit code 1 (use -v to see invocation)</p>
  
  <p>make: *** [ProjectName] Error 1</p>
  
  <p>** UPDATE **</p>
  
  <p>If you see "Class" as a class name anywhere that means I forgot to change it back to the real class name, which is ShirtOrder.</p>
  
  <p>Here is the code in my main cpp file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;cmath&gt;
  #include "ShirtOrder.h"
  
  using namespace std;
  
  
  /*********************************************************************************************************************
   ***************** FUNCTION PROTOTYPES -- FUNCTION PROTOTYPES -- FUNCTION PROTOTYPES -- FUNCTION PROTOTYPES **********
   *********************************************************************************************************************/
  
  bool uploadFile(string fName, unsigned long &amp;count, ShirtOrder* &amp;head);
  void clearLL(unsigned long &amp;count, ShirtOrder* &amp;head);
  void summaryByMethod(unsigned long count, ShirtOrder* head);
  void summaryByRegion(unsigned long count, ShirtOrder* head);
  
  /*********************************************************************************************************************
   ***************** MAIN FUNCTION -- MAIN FUNCTION -- MAIN FUNCTION -- MAIN FUNCTION -- MAIN FUNCTION *****************
   *********************************************************************************************************************/
  
  int main(int argc, char* argv[])
  {
      if (argc &lt; 2) // if only command line argument is program name
      {
          cout &lt;&lt; "No file name entered." &lt;&lt; endl;
      }
  
      else
      {
          ShirtOrder object;
          cout &lt;&lt; "Test run" &lt;&lt; endl;
      }
      return 0;
  }
  
  /**********************************************************************************************************
   ************ FUNCTION IMPLEMENTATIONS -- FUNCTION IMPLEMENTATIONS -- FUNCTION IMPLEMENTATIONS ************
   **********************************************************************************************************/
  
  bool uploadFile(string fName, unsigned long &amp;count, ShirtOrder* &amp;head)
  {
      return true;
  }
  
  void clearLL(unsigned long &amp;count, ShirtOrder* &amp;head)
  {
  
  }
  
  void summaryByMethod(unsigned long count, ShirtOrder* head)
  {
  
  }
  
  void summaryByRegion(unsigned long count, ShirtOrder* head)
  {
  
  }
  </code></pre>
  
  <p>my ShirtOrder.h file:</p>
  
  <pre><code>#ifndef SHIRTORDER_H_
  #define SHIRTORDER_H_
  
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;cmath&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  class ShirtOrder
  {
      friend ostream&amp; operator&lt;&lt;(ostream &amp;os, const ShirtOrder &amp;rhsObj);
  
  private:
      // the data members below are required (you may change identifiers)
      // there is no need for additional data members
      int orderYear, orderMonth, orderDay;
      char printMethod; // 's', 'i', or 'e'
      string message;
      int mediums; // number of medium shirts ordered
      int larges; // number of large shirts ordered
      int xls; // number of XL shirts ordered
      string shirtColor;
      string inkColor;
      string orderID;
      string region;
      string nameAndEmail;
  
      ShirtOrder* next; // new for P5
  
  public:
      ShirtOrder(); // default constructor
  
      ShirtOrder(int orderYear, int orderMonth, int orderDay,
                 char printMethod, string message, int mediums, int larges, int xls,
                 string shirtColor, string inkColor, string orderID,
                 string region, string nameAndEmail,
                 ShirtOrder *soPtr = NULL);
  
      ShirtOrder(const ShirtOrder &amp;otherObj);
  
      ~ShirtOrder(); // destructor                      // New for P5 (may not be in-line)
  
      ShirtOrder* getNext() const {return next;}        // New for P5 (may be in-line)
  
      void setNext(ShirtOrder* soPtr) {next = soPtr;}   // New for P5 (may be in-line)
  
      ShirtOrder operator=(const ShirtOrder &amp;rhsObj);   // New for P5 (may not be in-line)
  
      double getBlankCost() const;
      double getPrintingCost() const;
      double getTotalCost() const;
  
      int    getLetterCount() const;
      char   getPrintMethod() const {return printMethod;}
      int    getOrderYear() const {return orderYear;}
      int    getOrderMonth() const {return orderMonth;}
      int    getOrderDay() const {return orderDay;}
      int    getMediums() const {return mediums;}
      int    getLarges() const {return larges;}
      int    getXls() const{return xls;}
  
      string getShirtColor() const {return shirtColor;}
      string getInkColor() const {return inkColor;}
      string getOrderID() const {return orderID;}
      string getRegion() const {return region;}
      string getNameAndEmail() const {return nameAndEmail;}
      string getMessage() const {return message;}
  
      void  setOrderYear (int orderYear) {this-&gt;orderYear = orderYear;}
      void  setOrderMonth (int orderMonth) {this-&gt;orderMonth = orderMonth;}
      void  setOrderDay (int orderDay) {this-&gt;orderDay = orderDay;}
      void  setPrintMethod (char printMethod) {this-&gt;printMethod = printMethod;}
      void  setMessage (string message) {this-&gt;message = message; }
      void  setMediums (int mediums) {this-&gt;mediums = mediums;}
      void  setLarges (int larges) {this-&gt;larges = larges;}
      void  setXls (int xls) {this-&gt;xls = xls;}
      void  setShirtColor (string shirtColor) {this-&gt;shirtColor = shirtColor;}
      void  setInkColor (string inkColor) {this-&gt;inkColor = inkColor;}
      void  setOrderID (string orderID) {this-&gt;orderID = orderID;}
      void  setRegion (string region) {this-&gt;region = region;}
      void  setNameAndEmail (string nameAndEmail) {this-&gt;nameAndEmail = nameAndEmail;}
  
  }; // end declaration of class ShirtOrder
  
  /******************************************************************************************
   *********** MEMBER FUNCTION IMPLEMENTATIONS -- MEMBER FUNCTION IMPLEMENTATIONS ***********
   ******************************************************************************************/
  
  #endif /* SHIRTORDER_H_ */
  </code></pre>
  
  <p>my ShirtOrder.cpp file:</p>
  
  <pre><code>#include "ShirtOrder.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  /******************************************************************************************
   *********** MEMBER FUNCTION IMPLEMENTATIONS -- MEMBER FUNCTION IMPLEMENTATIONS ***********
   ******************************************************************************************/
  
  // Default Constructor
  ShirtOrder::ShirtOrder()
  {
      orderYear = 0;
      orderMonth = 0;
      orderDay = 0;
      printMethod = 'x'; // 's', 'i', or 'e'
      message = "";
      mediums = 0; // number of medium shirts ordered
      larges = 0; // number of large shirts ordered
      xls = 0; // number of XL shirts ordered
      shirtColor = "";
      inkColor = "";
      orderID = "";
      region = "";
      nameAndEmail = "";
  
      next = NULL;
  
      cout &lt;&lt; "Default constructor has run" &lt;&lt; endl;
  }
  
  // Other Constructor
  ShirtOrder::ShirtOrder(int orderYear, int orderMonth, int orderDay,
          char printMethod, string message, int mediums, int larges, int xls,
          string shirtColor, string inkColor, string orderID,
          string region, string nameAndEmail, ShirtOrder *soPtr)
  {
      this-&gt; orderYear = orderYear;
      this-&gt;orderMonth = orderMonth;
      this-&gt;orderDay = orderDay;
      this-&gt;printMethod = printMethod; // 's', 'i', or 'e'
      this-&gt;message = message;
      this-&gt;mediums = mediums; // number of medium shirts ordered
      this-&gt;larges = larges; // number of large shirts ordered
      this-&gt;xls = xls; // number of XL shirts ordered
      this-&gt;shirtColor = shirtColor;
      this-&gt;inkColor = inkColor;
      this-&gt;orderID = orderID;
      this-&gt;region = region;
      this-&gt;nameAndEmail = nameAndEmail;
  
      next = NULL;
  
      cout &lt;&lt; "Constructor Numero Dos has run" &lt;&lt; endl;
  }
  
  // Other, other constructor
  ShirtOrder::ShirtOrder(const ShirtOrder &amp;otherObj)
  {
      ShirtOrder object;
      object = otherObj;
      object.orderYear = otherObj.orderYear;
      object.orderMonth = otherObj.orderMonth;
      object.orderDay = otherObj.orderDay;
      object.printMethod = otherObj.printMethod;
      object.message = otherObj.message;
      object.mediums = otherObj.mediums;
      object.larges = otherObj.larges;
      object.xls = otherObj.xls;
      object.shirtColor = otherObj.shirtColor;
      object.inkColor = otherObj.inkColor;
      object.orderID = otherObj.orderID;
      object.region = otherObj.region;
      object.nameAndEmail = otherObj.nameAndEmail;
      object.next = otherObj.next;
  
      cout &lt;&lt; "Constructor Numero Tres has run" &lt;&lt; endl;
  }
  
  // DESTRUCTOR
  ShirtOrder::~ShirtOrder()
  {
      cout &lt;&lt; "Destructor has run" &lt;&lt; endl;
  }
  
  ShirtOrder operator=(const ShirtOrder &amp;rhsObj)
  {
  
  }
  
  // COME BACK TO REMOVE WHITESPACE
  int ShirtOrder::getLetterCount() const
  {
      string tempMessage = getMessage();
  
      int pos1 = tempMessage.find("\"") + 1; // find first occurrence of a double quotation mark and assign position +1 value to pos1
      int pos2 = tempMessage.rfind("\"") - 1; // find last occurrence of a double quotation mark and assign position -1 value to pos2
  
      tempMessage = tempMessage.substr(pos1, (pos2 - pos1)); // sets variable tempMessage to string between quotation marks
  
      return tempMessage.length();
  }
  
  double ShirtOrder::getBlankCost() const
  {
      return 0.0;
  }
  
  double ShirtOrder::getPrintingCost() const
  {
      return 0.0;
  }
  
  double ShirtOrder::getTotalCost() const
  {
      return 0.0;
  }
  </code></pre>