title: Linker error: _main already defined in *.obj
body: <p>The following code structure:</p>
  <h2>ArrayStack.h</h2>
  <pre><code>#ifndef ARRAY_STACK_H
  #define ARRAY_STACK_H
  #include &quot;Array.h&quot;
  // class ArrayStack
  #endif
  </code></pre>
  <h2>ArrayStack.cpp</h2>
  <pre><code>#include &quot;ArrayStack.h&quot;
  // ArrayStack's methods
  </code></pre>
  <h2>Array.h</h2>
  <pre><code>#ifndef ARRAY_HEADER
  #define ARRAY_HEADER
  #include &lt;iostream&gt;
  // class Array
  #endif
  </code></pre>
  <h2>Array.cpp</h2>
  <pre><code>#include &quot;Array.h&quot;
  // Array's methods
  </code></pre>
  <h2>main.cpp</h2>
  <pre><code>#include &quot;ArrayStack.h&quot;
  int main() {
      return 0;
  }
  </code></pre>
  <p>generates these errors:</p>
  <blockquote>
  <p>LNK1169 one or more multiply defined symbols found</p>
  <p>LNK2005   _main already defined in Array.obj</p>
  </blockquote>
  <p><strong>What's the problem here?</strong> Please do note that <code>Array.cpp</code> did have <code>int main()</code> defined in itself when it was included in the project for the first time, but no longer has it (neither does the <code>ArrayStack.cpp</code>). Also, the code compiles just fine when the <code>int main()</code> in <code>main.cpp</code> is omitted...</p>