title: Undefined Symbols for architecture x86_64: Compiling problems
body: <p>So I am trying to start an assignment, my professor gives us a Main.cpp, Main.h, Scanner.cpp, Scanner.h, and some other utilities.</p>
  
  <p>My job is to create a Similarity class to compare documents using the cosine and Jaccard coefficients. However, I can not seem to get the project linked correctly, therefore I am unable to start on the actual code.</p>
  
  <p>After trying for several hours to see what I am doing wrong, I need fresh eyes to see what I am doing wrong, I suspect it is obvious.</p>
  
  <p>Here is the Main.cpp</p>
  
  <pre><code>#include "Main.h"
  
  using namespace std;
  
  static const string TAG = "Main: ";
  
  int main(int argc, char *argv[])
  {
    string inStreamName;
    string logStreamName;
    string outStreamName;
  
    ofstream outStream;
    string timeCallOutput;
    Scanner inStream;
  
    Similarity similarity;
  
    ///////////////////////////////////////////////////////////////
    // Boilerplate for naming files and opening files
    Utils::CheckArgs(3, argc, argv, "infilename outfilename logfilename");
    outStreamName = static_cast&lt;string&gt;(argv[2]);
    logStreamName = static_cast&lt;string&gt;(argv[3]);
  
    Utils::FileOpen(outStream, outStreamName);
    Utils::LogFileOpen(logStreamName);
  
    timeCallOutput = Utils::timecall("beginning");
    Utils::logStream &lt;&lt; timeCallOutput &lt;&lt; endl;
    Utils::logStream &lt;&lt; TAG &lt;&lt; "Beginning execution" &lt;&lt; endl;
  
    Utils::logStream &lt;&lt; TAG &lt;&lt; "outfile '" &lt;&lt; outStreamName &lt;&lt; "'" &lt;&lt; endl;
    Utils::logStream &lt;&lt; TAG &lt;&lt; "logfile '" &lt;&lt; logStreamName &lt;&lt; "'" &lt;&lt; endl;
    Utils::logStream.flush();
  
    ///////////////////////////////////////////////////////////////
    // What follows here is the real work of this code.
    //   read the entire input file and echo it back
    //   compute the two similarity coefficients
  
    inStreamName = static_cast&lt;string&gt;(argv[1]);
    inStream.openFile(inStreamName);
    Utils::logStream &lt;&lt; TAG &lt;&lt; "infile '" &lt;&lt; inStreamName &lt;&lt; "'" &lt;&lt; endl;
    Utils::logStream.flush();
  
    similarity.readData(inStream);
  
    outStream &lt;&lt; TAG &lt;&lt; "Data Begin\n" &lt;&lt; similarity.toString() &lt;&lt; endl;
    outStream &lt;&lt; TAG &lt;&lt; "Data End\n" &lt;&lt; endl;
    outStream.flush();
    inStream.close();
  
    outStream &lt;&lt; TAG &lt;&lt; "Begin similarity computation" &lt;&lt; endl;
    outStream &lt;&lt; TAG &lt;&lt; "Maximum Jaccard similarity:\n" &lt;&lt;
                         similarity.maxJaccard() &lt;&lt; endl;
    outStream &lt;&lt; TAG &lt;&lt; "Maximum cosine similarity:\n" &lt;&lt;
                         similarity.maxCosine() &lt;&lt; endl;
    outStream &lt;&lt; TAG &lt;&lt; "End similarity computation" &lt;&lt; endl;
    outStream.flush();
  
    ///////////////////////////////////////////////////////////////
    // Boilerplate for terminating gracefully
    Utils::logStream &lt;&lt; TAG &lt;&lt; "Ending execution" &lt;&lt; endl;
    timeCallOutput = Utils::timecall("ending");
    Utils::logStream &lt;&lt; timeCallOutput &lt;&lt; endl;
    Utils::logStream.flush();
  
    outStream.flush();
    Utils::FileClose(outStream);
  
    Utils::FileClose(Utils::logStream);
  
    return 0;
  }
  </code></pre>
  
  <p>And the Main.h</p>
  
  <pre><code>#ifndef MAIN_H
  #define MAIN_H
  
  #include "../../Utilities/Utils.h"
  #include "../../Utilities/Scanner.h"
  
  #include "Similarity.h"
  
  class Main
  {
  public:
    int main();
    virtual ~Main();
  
  private:
  
  };
  
  #endif // MAIN_H
  </code></pre>
  
  <p>My Similarity.cpp</p>
  
  <pre><code>#include "Similarity.h"
  
  using namespace std;
  
  void readData(Scanner&amp; inStream){
  }
  
  string maxCosine(){
      return "cosine";
  }
  
  string maxJaccard(){
      return "jaccard";
  }
  
  string toString(){
      return "toString";
  }
  </code></pre>
  
  <p>And finally my Similarity.h:</p>
  
  <pre><code>#ifndef SIMILARITY_H
  #define SIMILARITY_H
  
  #include "../../Utilities/Scanner.h"
  
  class Similarity
  {
  public:
      Similarity();
      virtual ~Similarity();
  
      void readData(Scanner&amp; inStream);
      string maxCosine();
      string maxJaccard();
      string toString();
  private:
  
  };
  
  #endif
  </code></pre>
  
  <p>When I use the makefile he provided, and the one I have to use in order for his script to work to grade it I get this error:</p>
  
  <pre><code>g++ -O3 -Wall -o Similarity.o -c Similarity.cpp
  g++ -O3 -Wall -o Aprog Main.o Similarity.o Scanner.o ScanLine.o Utils.o 
  Undefined symbols for architecture x86_64:
    "Similarity::maxJaccard()", referenced from:
        _main in Main.o
    "Similarity::readData(Scanner&amp;)", referenced from:
        _main in Main.o
    "Similarity::toString()", referenced from:
        _main in Main.o
    "Similarity::maxCosine()", referenced from:
        _main in Main.o
    "Similarity::Similarity()", referenced from:
        _main in Main.o
    "Similarity::~Similarity()", referenced from:
        _main in Main.o
  ld: symbol(s) not found for architecture x86_64
  collect2: ld returned 1 exit status
  make: *** [Aprog] Error 1
  </code></pre>
  
  <p>Thank you for reading through all that, any suggestions or solutions would be greatly appreciated.</p>