title: Xcode C++ :: Duplicate Symbols for Architecture x86_64
body: <p>I am new to Xcode and when I build the following code (an MWE), I get the following error</p>
  
  <blockquote>
    <p>ld: 3 duplicate symbols for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)</p>
  </blockquote>
  
  <p>I have three files as following;</p>
  
  <blockquote>
    <p>main.cpp</p>
  </blockquote>
  
  <pre><code>#include "B.cpp"
  int main() {
    square(5);
    return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>B.cpp</p>
  </blockquote>
  
  <pre><code>#include "A.cpp"
  
  void square(int n){
    display(n*n);
  }
  </code></pre>
  
  <blockquote>
    <p>A.cpp</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void display(int num){
    cout&lt;&lt;num;
  }
  </code></pre>
  
  <p>I have tried different methods mentioned on stack overflow like change "Build Active Architecture Only" to "Yes" and some others but the error still persists.</p>