title: Combining multiple .o files into an executable
body: <p>I'm trying to combine object files created from C++ files into an executable using <code>gcc</code>. Unfortunately, <code>gcc</code> is giving me thousands of <code>undefined reference</code> errors to strings, arrays, etc.</p>
  
  <p>I am doing this on a Windows machine, so no terminal commands; only cmd commands.</p>
  
  <p>I'm simply doing:</p>
  
  <pre><code>gcc a.o b.o c.o -o prgm.exe
  </code></pre>
  
  <p>What am I missing/doing wrong?</p>
  
  <p>EDIT:</p>
  
  <p>I recreated the .o files with g++ doing:
  <code>g++ a.cpp -g -c -Wall -std=c++0x -lSDLmain -lSDL -lSDL_image -lSDL_ttf -IC:\SDL-1.2.14\include -o a.o</code>, where a.cpp and a.o are the directories where i keep the files, not the g++ directory</p>
  
  <p>Then, I did <code>g++ a.o b.o c.o -o prgm.exe</code>. This gave dozens (I guess that's an improvement?) errors like </p>
  
  <pre><code>undefined reference to `_SDL_SetColorKey'
  </code></pre>
  
  <p>but I included SDL didnt I?</p>
  
  <p>The final error from this is:</p>
  
  <pre><code>c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../li
  bmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `_WinMain
  @16'
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p><code>int main(int argc, char * argv[])</code> is in the code</p>