title: Cygwin and SDL 2.0 : how to compile?
body: <p>I've downloaded SDL2.0 like this:</p>
  
  <pre><code>~/tmp&gt;wget http://www.libsdl.org/tmp/release/SDL2-2.0.0.tar.gz
  </code></pre>
  
  <p>Then I extracted it, went into the directory, and did <code>./configure &amp;&amp; make &amp;&amp; make install</code>. Everything went fine. Now I've made a very simple sample (see far below). My problem is when I try to compile it doesn't work, So I copied SDL2.dll into the current directory and tried all combinations I know without success:</p>
  
  <pre><code>~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -l SDL2.dll
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -lSDL2.dll
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -L SDL2.dll
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2.dll
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -l SDL2
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -lSDL2
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -L SDL2
  ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2
  </code></pre>
  
  <p>All errors are either:</p>
  
  <pre><code>/usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lSDL2.dll
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>933012@F9ZW00118371 ~/tmp/SDL2-2.0.0 &gt;gcc -o tt tt.c -I/home/933012/tmp/SDL2-2.0.0/include -LSDL2.dll
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xe): undefined reference to `SDL_Init'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x42): undefined reference to `SDL_CreateWindow'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x50): undefined reference to `SDL_GetWindowSurface'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x67): undefined reference to `SDL_RWFromFile'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x77): undefined reference to `SDL_LoadBMP_RW'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0x9c): undefined reference to `SDL_UpperBlit'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xa7): undefined reference to `SDL_UpdateWindowSurface'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xb2): undefined reference to `SDL_FreeSurface'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xda): undefined reference to `SDL_PollEvent'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xef): undefined reference to `SDL_DestroyWindow'
  /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o:tt.c:(.text+0xf4): undefined reference to `SDL_Quit'
  /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/Users/933012/AppData/Local/Temp/ccHZGVRX.o: bad reloc address 0x20 in section `.eh_frame'
  /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>How would you do?</p>
  
  <p>Here's my source code I try to compile:</p>
  
  <pre><code>#include &lt;SDL.h&gt;
  
  int main(int argc, char *argv[]) {
      int running;
      SDL_Window *window;
      SDL_Surface *windowsurface;
      SDL_Surface *image;
      SDL_Event event;
  
      SDL_Init(SDL_INIT_VIDEO);
  
      window = SDL_CreateWindow("Hello World",
                                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                592, 460, SDL_WINDOW_SHOWN);
      windowsurface = SDL_GetWindowSurface(window);
  
      image = SDL_LoadBMP("exampleimage.bmp");
      SDL_BlitSurface(image, NULL, windowsurface, NULL);
  
      SDL_UpdateWindowSurface(window);
      SDL_FreeSurface(image);
  
      running = 1;
      while (running) {
          while (SDL_PollEvent(&amp;event) != 0) {
              if (event.type == SDL_QUIT) {
                  running = 0;
                  break;
              }
          }
      }
      SDL_DestroyWindow(window);
      SDL_Quit();
      return 0;
   }
  </code></pre>