title: Issue on makefile using mingw32 and SDL2 (undefined SDL_main ... again)
body: <p>I'm struggling a bit with this announcing error a lot of people get but I didn't manage to solve it looking at others makefiles. 
  I will first explain what I aim and what I'm doing.</p>
  
  <ol>
  <li>I'm creating a lib, called MyLib that uses SDL2 and OpenGL;</li>
  <li>All references to SDL2 are there except the main function;</li>
  <li>This lib is using makefile as well with mingw and return the *.a file.</li>
  <li>I create a dummy exe app that contains the main function and links to MyLib by calling the Starting point object.</li>
  <li>When trying to link the Dummy exe I'm getting the following error.</li>
  </ol>
  
  <blockquote>
    <p>g++ -c ../../src/main.cpp ../../src/DummyGame.cpp -Wall -std=c++11
    -DMINGW32 -DUSE_STD -DUSE_SDL
        -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32  -I../../src -I../../include -I../../../../libs/include -I..
        /../../../MyLib/src  -L../../../../MyLib/lib -L../../../../libs/lib/mingw32/lib -lmingw32 -lSDL2
        main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -lopengl32 -lMyLib
        g++  -Wall -std=c++11 -DMINGW32 -DUSE_STD -DUSE_SDL -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32  -I../..
        /src -I../../include -I../../../../libs/include -I../../../../MyLib/src  -L../../../../MyLib/lib
         -L../../../../libs/lib/mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -l
        opengl32 -lMyLib  -o Dummy.mingw32.exe
        ../../../../libs/lib/mingw32/lib/libSDL2main.a(SDL_windows_main.o): In
    function <code>console_main':
        /Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/main/windows/SDL_windows_main.c:140:
    und
        efined reference to</code>SDL_main'
        collect2.exe: error: ld returned 1 exit status
        Makefile.mingw:26: recipe for target 'Dummy.mingw32.exe' failed
        mingw32-make.exe: [Dummy.mingw32.exe] Error 1
        --
        xcopy /Y Dummy.mingw32.exe "../../bin"
        File not found - Dummy.mingw32.exe
        0 File(s) copied
        Makefile.mingw:34: recipe for target 'install' failed
        mingw32-make.exe:  [install] Error 4
        --</p>
  </blockquote>
  
  <p>This is how the main.cpp file look like:</p>
  
  <pre><code>#include "DummyGame.h"
  
  using namespace Dummy;
  
  #ifdef __cplusplus
  extern "C" 
  #endif
  int main(int argc, char *argv[])
  {
      DummyGame *game = new DummyGame("Dummy", 720, 480);
      game-&gt;run(); 
  
      return 0;
  }
  </code></pre>
  
  <p>DummyGame.h includes MyLib headers that will include SDL2 headers.</p>
  
  <p>I am using the correct 32 bits version of SDL2 from folder "i686-w64-mingw32"</p>
  
  <p>This is my actual makefile:</p>
  
  <pre><code>CP = xcopy /Y
  RM = del /F
  
  TARGET = Dummy.mingw32.exe
  
  PROJDIR = ../..
  BASEDIR = $(PROJDIR)/../..
  SRCDIR = $(PROJDIR)/src
  INSTALLDIR = $(PROJDIR)/bin
  
  INCLUDE = -I$(SRCDIR) -I$(PROJDIR)/include -I$(BASEDIR)/libs/include -I$(BASEDIR)/MyLib/src 
  
  LIBSPATH = -L$(BASEDIR)/MyLib/lib -L$(BASEDIR)/libs/lib/mingw32/lib
  
  LIBSFLAG = -lmingw32 -lSDL2main -lSDL2 -mwindows -lSDL2_image -lSDL2_ttf -lopengl32 -lHikeGDK
  LDFLAGS = $(INCLUDE) $(LIBSPATH) $(LIBSFLAG) 
  CXXFLAGS = -Wall -std=c++11 -DMINGW32 -DUSE_STD -DUSE_SDL -DUSE_SDL_IMAGE -DUSE_OPENGL -DOPENGL32 
  LIBS = $(CXXFLAGS) $(LDFLAGS)
  
  MODULES = $(wildcard $(SRCDIR)/*.cpp)
  OBJS = $(wildcard *.o)
  
  all: $(TARGET)
  
  $(TARGET): $(MODULES)
      $(CXX) -c $(MODULES) $(LIBS)
      $(CXX) $(OBJS) $(LIBS) -o $@
  
  clean:
      $(RM) $(OBJS)
      $(RM) $(TARGET)
  
  install: 
      $(CP) $(TARGET) "$(INSTALLDIR)"
  </code></pre>
  
  <p>Thanks for your help.</p>