title: SDL doesn't compile in native enviroment
body: <p>I'm trying to compile this piece of code with SDL</p>
  
  <pre><code>#include &lt;SDL.h&gt;
  int main(int argc, char * argv[]){
      return 0;
  }
  </code></pre>
  
  <p>The file itself compiles fine with </p>
  
  <pre><code>g++ -c main.cpp -ISDL/include
  </code></pre>
  
  <p>But compiling with following command in cygwin using g++</p>
  
  <pre><code>g++ -o test main.o  -lSDL2 -lSDL2main -L SDL/lib/x64
  </code></pre>
  
  <p>produces this huge error... it seems to me like a problem of SDL itself...</p>
  
  <pre><code>$ g++ -o test main.o  -lSDL2 -lSDL2main -L SDL/lib/x64
  Warning: corrupt .drectve at end of def file
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[main]+0xe): undefined reference to `SDL_SetMainReady'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[main]+0xe): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_SetMainReady'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x29): undefined reference to `SDL_wcslen'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x29): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_wcslen'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x46): undefined reference to `SDL_iconv_string'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x46): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_iconv_string'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x7d): undefined reference to `SDL_malloc'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0x7d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_malloc'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0xb8): undefined reference to `SDL_free'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0xb8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_free'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0xc2): undefined reference to `SDL_free'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[WinMain]+0xc2): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_free'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ParseCommandLine]+0x4a): undefined reference to `SDL_isspace'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ParseCommandLine]+0x4a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_isspace'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ParseCommandLine]+0x146): undefined reference to `SDL_isspace'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ParseCommandLine]+0x146): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `SDL_isspace'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ShowError]+0x10): undefined reference to `__imp___iob_func'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ShowError]+0x10): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___iob_func'
  collect2: Fehler: ld gab 1 als Ende-Status zurück
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Altering the library order gives following error</p>
  
  <pre><code>$ g++ -o test main.o  -lSDL2main -lSDL2 -L SDL/lib/x64
  Warning: corrupt .drectve at end of def file
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ShowError]+0x10): undefined reference to `__imp___iob_func'
  SDL/lib/x64/SDL2main.lib(./x64/Release/SDL_windows_main.obj):(.text[ShowError]+0x10): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___iob_func'
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_SetMainReady' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_free' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_malloc' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_iconv_string' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_wcslen' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  SDL/lib/x64/SDL2.lib(SDL2.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_SDL_isspace' defined in .idata$5 section in SDL/lib/x64/SDL2.lib(SDL2.dll.b)
  collect2: Fehler: ld gab 1 als Ende-Status zurück
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>I've found a workarround:
  I'm now using mingw32 to compile my files:</p>
  
  <pre><code>i686-pc-mingw32-g++ main.cpp -o main -ISDL/i686-w64-mingw32/include/SDL2/ -LSDL/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDl2 -static-libgcc -static-libstdc++
  </code></pre>
  
  <p>I also copied the SDL binary to the folder of my executable and now everything works just fine</p>