title: What's with these g++ "multiple definition" errors?
body: <p>I'm in the early stages (read:just started yesterday) of a project, and I'm setting up my initial makefile. It's very simplistic. Here's the full contents of the file:</p>
  
  <pre><code>all: main.o resource.o
      g++ -o output.exe main.o resource.o
  
  main.o: main.cpp main.h resource.h
      g++ -mwindows -o main.o main.cpp
  
  resource.o: resource.rc
      windres resource.rc resource.o
  
  clean:
      rm *.o 
  </code></pre>
  
  <p>At this point I think it's important to mention that I'm working on Windows, so I'm doing all of this in either Powershell with MinGW g++ 4.5.2 or else with Cygwin and g++ 3.4.4 (I've tried both; same errors).</p>
  
  <p>Without printing the contents of all the above-listed files, it suffices to say that main.h contains a reference to windows.h and resource.h, main.cpp contains a reference to main.h and a few functions, most importantly an int WINAPI WinMain(...) function and an LRESULT CALLBACK WndProc(...) function, resource.rc contains resource definition statements for a simple menubar with a file menu and a dummy second menu as well as a reference to resource.h, and resource.h simply contains #define statements for the IDs used in resource.rc.</p>
  
  <p>Now, I can compile both resource.rc and main.h separately from each other and get those two nice .o files. However, when I try to link them and produce output.exe, I get the following scary list of errors, none of which I really understand:</p>
  
  <pre><code>main.o:main.cpp:(.text+0x0): multiple definition of `mainCRTStartup'
  c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../crt2.o:crt1.c:(.text+0x160): first defined here
  main.o:main.cpp:(.text+0x0): multiple definition of `WinMainCRTStartup'
  c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../crt2.o:crt1.c:(.text+0x140): first defined here
  collect2: ld returned 1 exit status
  make: *** [all] Error 1
  </code></pre>
  
  <p>The above is generated in Powershell. Cygwin gives a very similar list of errors, still centering around "multiple definition" statements. The multiple definitions seem to be originating in C:/mingw/lib/crt2.o, and possibly another file named crt1.c, which would seem to be more helpful since obviously C is far more human readable than a .o file, but I can't find anything with that title anywhere within the C:\MinGW folder.</p>
  
  <p>Any direction at all would be helpful, because at the moment I'm pretty lost.</p>
  
  <p>EDIT:
  The only #include statement in main.cpp:</p>
  
  <pre><code>#include "main.h"
  </code></pre>
  
  <p>The contents of main.h:</p>
  
  <pre><code>#ifndef _MAIN_H_
      #define _MAIN_H_
  
      #include &lt;windows.h&gt;
      #include "resource.h"
  
  #endif
  </code></pre>