title: I can't compile ffmpeg, don't know how to install sdl2 properly
body: <p>I'm compiling ffmpeg, on windows, with mingw-w64, and I need SDL2 so that the ffplay in ffmpeg compiles. I installed mingw-w64 using the web installer, I installed msys (to run the <code>./configure</code> that comes with ffmpeg) using the all in one package provided by mingw-w64. I installed SDL2 by downloading dev binaries from their site and running <code>make native</code> in msys.</p>
  
  <p>So, it seems SDL2 isn't installed properly or something.</p>
  
  <p>Here is the problematic part in <code>./configure</code>:</p>
  
  <pre><code>if enabled sdl2; then
      echo "SDL2-1"
      SDL2_CONFIG="${cross_prefix}sdl2-config"
      test_pkg_config sdl2 "sdl2 &gt;= 2.0.1 sdl2 &lt; 2.1.0" SDL_events.h SDL_PollEvent
      echo "SDL2-2"
      if disabled sdl2 &amp;&amp; "${SDL2_CONFIG}" --version &gt; /dev/null 2&gt;&amp;1; then
          echo "SDL2-3"
          sdl2_cflags=$("${SDL2_CONFIG}" --cflags)
          sdl2_extralibs=$("${SDL2_CONFIG}" --libs)
          echo "SDL2-config ${SDL2_CONFIG}"
          echo "SDL2-cflags ${sdl2_cflags}"
          echo "SDL2-libs ${sdl2_extralibs}"
          test_cpp_condition SDL.h "(SDL_MAJOR_VERSION&lt;&lt;16 | SDL_MINOR_VERSION&lt;&lt;8 | SDL_PATCHLEVEL) &gt;= 0x020001" $sdl2_cflags &amp;&amp;
          echo "SDL2-4" &amp;&amp;
          test_cpp_condition SDL.h "(SDL_MAJOR_VERSION&lt;&lt;16 | SDL_MINOR_VERSION&lt;&lt;8 | SDL_PATCHLEVEL) &lt; 0x020100" $sdl2_cflags &amp;&amp;
          echo "SDL2-5" &amp;&amp;
          check_func_headers SDL_events.h SDL_PollEvent $sdl2_extralibs $sdl2_cflags &amp;&amp;
          echo "SDL2-6-final" &amp;&amp;
              enable sdl2
      fi
      if test $target_os = "mingw32"; then
          sdl2_extralibs=$(filter_out '-mwindows' $sdl2_extralibs)
      fi
  fi
  </code></pre>
  
  <p>This is the result of it, it never gets to <code>SDL2-6-final</code> and <code>enable sdl2</code></p>
  
  <pre><code>SDL2-1
  SDL2-2
  SDL2-3
  SDL2-config sdl2-config
  SDL2-cflags -I/usr/include/SDL2 -Dmain=SDL_main
  SDL2-libs -L/usr/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
  SDL2-4
  SDL2-5
  </code></pre>
  
  <p>This is the sdl2 installation log:</p>
  
  <pre><code>User@NEW-PC /c/Users/User/Downloads/games/compilers/SDL2-2.0.9
  $ make native
  make install-package arch=i686-w64-mingw32 prefix=/usr
  make[1]: Entering directory `/c/Users/User/Downloads/games/compilers/SDL2-2.0.9'
  `bin/sdl2-config' -&gt; `/usr/bin/sdl2-config'
  `bin/SDL2.dll' -&gt; `/usr/bin/SDL2.dll'
  `include' -&gt; `/usr/include'
  `include/SDL2' -&gt; `/usr/include/SDL2'
  `include/SDL2/begin_code.h' -&gt; `/usr/include/SDL2/begin_code.h'
  `include/SDL2/close_code.h' -&gt; `/usr/include/SDL2/close_code.h'
  `include/SDL2/SDL.h' -&gt; `/usr/include/SDL2/SDL.h'
  `include/SDL2/SDL_assert.h' -&gt; `/usr/include/SDL2/SDL_assert.h'
  `include/SDL2/SDL_atomic.h' -&gt; `/usr/include/SDL2/SDL_atomic.h'
  `include/SDL2/SDL_audio.h' -&gt; `/usr/include/SDL2/SDL_audio.h'
  `include/SDL2/SDL_bits.h' -&gt; `/usr/include/SDL2/SDL_bits.h'
  `include/SDL2/SDL_blendmode.h' -&gt; `/usr/include/SDL2/SDL_blendmode.h'
  `include/SDL2/SDL_clipboard.h' -&gt; `/usr/include/SDL2/SDL_clipboard.h'
  `include/SDL2/SDL_config.h' -&gt; `/usr/include/SDL2/SDL_config.h'
  `include/SDL2/SDL_cpuinfo.h' -&gt; `/usr/include/SDL2/SDL_cpuinfo.h'
  `include/SDL2/SDL_egl.h' -&gt; `/usr/include/SDL2/SDL_egl.h'
  `include/SDL2/SDL_endian.h' -&gt; `/usr/include/SDL2/SDL_endian.h'
  `include/SDL2/SDL_error.h' -&gt; `/usr/include/SDL2/SDL_error.h'
  `include/SDL2/SDL_events.h' -&gt; `/usr/include/SDL2/SDL_events.h'
  `include/SDL2/SDL_filesystem.h' -&gt; `/usr/include/SDL2/SDL_filesystem.h'
  `include/SDL2/SDL_gamecontroller.h' -&gt; `/usr/include/SDL2/SDL_gamecontroller.h'
  `include/SDL2/SDL_gesture.h' -&gt; `/usr/include/SDL2/SDL_gesture.h'
  `include/SDL2/SDL_haptic.h' -&gt; `/usr/include/SDL2/SDL_haptic.h'
  `include/SDL2/SDL_hints.h' -&gt; `/usr/include/SDL2/SDL_hints.h'
  `include/SDL2/SDL_joystick.h' -&gt; `/usr/include/SDL2/SDL_joystick.h'
  `include/SDL2/SDL_keyboard.h' -&gt; `/usr/include/SDL2/SDL_keyboard.h'
  `include/SDL2/SDL_keycode.h' -&gt; `/usr/include/SDL2/SDL_keycode.h'
  `include/SDL2/SDL_loadso.h' -&gt; `/usr/include/SDL2/SDL_loadso.h'
  `include/SDL2/SDL_log.h' -&gt; `/usr/include/SDL2/SDL_log.h'
  `include/SDL2/SDL_main.h' -&gt; `/usr/include/SDL2/SDL_main.h'
  `include/SDL2/SDL_messagebox.h' -&gt; `/usr/include/SDL2/SDL_messagebox.h'
  `include/SDL2/SDL_mouse.h' -&gt; `/usr/include/SDL2/SDL_mouse.h'
  `include/SDL2/SDL_mutex.h' -&gt; `/usr/include/SDL2/SDL_mutex.h'
  `include/SDL2/SDL_name.h' -&gt; `/usr/include/SDL2/SDL_name.h'
  `include/SDL2/SDL_opengl.h' -&gt; `/usr/include/SDL2/SDL_opengl.h'
  `include/SDL2/SDL_opengles.h' -&gt; `/usr/include/SDL2/SDL_opengles.h'
  `include/SDL2/SDL_opengles2.h' -&gt; `/usr/include/SDL2/SDL_opengles2.h'
  `include/SDL2/SDL_opengles2_gl2.h' -&gt; `/usr/include/SDL2/SDL_opengles2_gl2.h'
  `include/SDL2/SDL_opengles2_gl2ext.h' -&gt; `/usr/include/SDL2/SDL_opengles2_gl2ext.h'
  `include/SDL2/SDL_opengles2_gl2platform.h' -&gt; `/usr/include/SDL2/SDL_opengles2_gl2platform.h'
  `include/SDL2/SDL_opengles2_khrplatform.h' -&gt; `/usr/include/SDL2/SDL_opengles2_khrplatform.h'
  `include/SDL2/SDL_opengl_glext.h' -&gt; `/usr/include/SDL2/SDL_opengl_glext.h'
  `include/SDL2/SDL_pixels.h' -&gt; `/usr/include/SDL2/SDL_pixels.h'
  `include/SDL2/SDL_platform.h' -&gt; `/usr/include/SDL2/SDL_platform.h'
  `include/SDL2/SDL_power.h' -&gt; `/usr/include/SDL2/SDL_power.h'
  `include/SDL2/SDL_quit.h' -&gt; `/usr/include/SDL2/SDL_quit.h'
  `include/SDL2/SDL_rect.h' -&gt; `/usr/include/SDL2/SDL_rect.h'
  `include/SDL2/SDL_render.h' -&gt; `/usr/include/SDL2/SDL_render.h'
  `include/SDL2/SDL_revision.h' -&gt; `/usr/include/SDL2/SDL_revision.h'
  `include/SDL2/SDL_rwops.h' -&gt; `/usr/include/SDL2/SDL_rwops.h'
  `include/SDL2/SDL_scancode.h' -&gt; `/usr/include/SDL2/SDL_scancode.h'
  `include/SDL2/SDL_sensor.h' -&gt; `/usr/include/SDL2/SDL_sensor.h'
  `include/SDL2/SDL_shape.h' -&gt; `/usr/include/SDL2/SDL_shape.h'
  `include/SDL2/SDL_stdinc.h' -&gt; `/usr/include/SDL2/SDL_stdinc.h'
  `include/SDL2/SDL_surface.h' -&gt; `/usr/include/SDL2/SDL_surface.h'
  `include/SDL2/SDL_system.h' -&gt; `/usr/include/SDL2/SDL_system.h'
  `include/SDL2/SDL_syswm.h' -&gt; `/usr/include/SDL2/SDL_syswm.h'
  `include/SDL2/SDL_test.h' -&gt; `/usr/include/SDL2/SDL_test.h'
  `include/SDL2/SDL_test_assert.h' -&gt; `/usr/include/SDL2/SDL_test_assert.h'
  `include/SDL2/SDL_test_common.h' -&gt; `/usr/include/SDL2/SDL_test_common.h'
  `include/SDL2/SDL_test_compare.h' -&gt; `/usr/include/SDL2/SDL_test_compare.h'
  `include/SDL2/SDL_test_crc32.h' -&gt; `/usr/include/SDL2/SDL_test_crc32.h'
  `include/SDL2/SDL_test_font.h' -&gt; `/usr/include/SDL2/SDL_test_font.h'
  `include/SDL2/SDL_test_fuzzer.h' -&gt; `/usr/include/SDL2/SDL_test_fuzzer.h'
  `include/SDL2/SDL_test_harness.h' -&gt; `/usr/include/SDL2/SDL_test_harness.h'
  `include/SDL2/SDL_test_images.h' -&gt; `/usr/include/SDL2/SDL_test_images.h'
  `include/SDL2/SDL_test_log.h' -&gt; `/usr/include/SDL2/SDL_test_log.h'
  `include/SDL2/SDL_test_md5.h' -&gt; `/usr/include/SDL2/SDL_test_md5.h'
  `include/SDL2/SDL_test_memory.h' -&gt; `/usr/include/SDL2/SDL_test_memory.h'
  `include/SDL2/SDL_test_random.h' -&gt; `/usr/include/SDL2/SDL_test_random.h'
  `include/SDL2/SDL_thread.h' -&gt; `/usr/include/SDL2/SDL_thread.h'
  `include/SDL2/SDL_timer.h' -&gt; `/usr/include/SDL2/SDL_timer.h'
  `include/SDL2/SDL_touch.h' -&gt; `/usr/include/SDL2/SDL_touch.h'
  `include/SDL2/SDL_types.h' -&gt; `/usr/include/SDL2/SDL_types.h'
  `include/SDL2/SDL_version.h' -&gt; `/usr/include/SDL2/SDL_version.h'
  `include/SDL2/SDL_video.h' -&gt; `/usr/include/SDL2/SDL_video.h'
  `include/SDL2/SDL_vulkan.h' -&gt; `/usr/include/SDL2/SDL_vulkan.h'
  `lib/cmake' -&gt; `/usr/lib/cmake'
  `lib/cmake/SDL2' -&gt; `/usr/lib/cmake/SDL2'
  `lib/cmake/SDL2/sdl2-config.cmake' -&gt; `/usr/lib/cmake/SDL2/sdl2-config.cmake'
  `lib/libSDL2.a' -&gt; `/usr/lib/libSDL2.a'
  `lib/libSDL2.dll.a' -&gt; `/usr/lib/libSDL2.dll.a'
  `lib/libSDL2.la' -&gt; `/usr/lib/libSDL2.la'
  `lib/libSDL2main.a' -&gt; `/usr/lib/libSDL2main.a'
  `lib/libSDL2main.la' -&gt; `/usr/lib/libSDL2main.la'
  `lib/libSDL2_test.a' -&gt; `/usr/lib/libSDL2_test.a'
  `lib/libSDL2_test.la' -&gt; `/usr/lib/libSDL2_test.la'
  `lib/pkgconfig' -&gt; `/usr/lib/pkgconfig'
  `lib/pkgconfig/sdl2.pc' -&gt; `/usr/lib/pkgconfig/sdl2.pc'
  `share/aclocal/sdl2.m4' -&gt; `/usr/share/aclocal/sdl2.m4'
  make[1]: Leaving directory `/c/Users/User/Downloads/games/compilers/SDL2-2.0.9'
  </code></pre>
  
  <p>And this is what happens when I just comment out that last check in <code>./configure</code> and enable sdl2 anyway:</p>
  
  <p><code>c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2main.a when searching for -lSDL2main</code></p>
  
  <p><code>c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2.dll.a when searching for -lSDL2</code></p>
  
  <p><code>c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2</code></p>
  
  <p>I tried using msys2 instead, it compiles, but the debugger there doesn't work for some reason. I need to run the source code of ffmpeg in debugger to have a chance of understanding anything there. I need to use the combination of codeblocks and gdb, and programs compiled with msys2 use weird pathnames like /c/bla/bla/bla/main.c, and codeblocks is righteously weirded out by that. The mingw-w64 uses more sane pathnames, I just checked that.</p>
  
  <p>Checked <code>ffbuild/config.log</code>, the problem is here:</p>
  
  <pre><code>`c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2`
  </code></pre>
  
  <p>More in full:</p>
  
  <pre><code>test_pkg_config sdl2 sdl2 &gt;= 2.0.1 sdl2 &lt; 2.1.0 SDL_events.h SDL_PollEvent
  pkg-config --exists --print-errors sdl2 &gt;= 2.0.1 sdl2 &lt; 2.1.0
  check_func_headers SDL_events.h SDL_PollEvent -Dmain=SDL_main -IC:/msys/include/SDL2 -mwindows -LC:/msys/lib -lmingw32 -lSDL2main -lSDL2
  test_ld cc -Dmain=SDL_main -IC:/msys/include/SDL2 -mwindows -LC:/msys/lib -lmingw32 -lSDL2main -lSDL2
  test_cc -Dmain=SDL_main -IC:/msys/include/SDL2 -mwindows -LC:/msys/lib
  BEGIN /tmp/ffconf.atBoPojc/test.c
      1   #include &lt;SDL_events.h&gt;
      2   #include &lt;stdint.h&gt;
      3   long check_SDL_PollEvent(void) { return (long) SDL_PollEvent; }
      4   int main(void) { int ret = 0;
      5    ret |= ((intptr_t)check_SDL_PollEvent) &amp; 0xFFFF;
      6   return ret; }
  END /tmp/ffconf.atBoPojc/test.c
  gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 -D__printf__=__gnu_printf__ -D_WIN32_WINNT=0x0600 -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -Dmain=SDL_main -IC:/msys/include/SDL2 -mwindows -LC:/msys/lib -c -o /tmp/ffconf.atBoPojc/test.o /tmp/ffconf.atBoPojc/test.c
  C:/Users/User/AppData/Local/Temp/ffconf.atBoPojc/test.c: In function 'check_SDL_PollEvent':
  C:/Users/User/AppData/Local/Temp/ffconf.atBoPojc/test.c:3:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   long check_SDL_PollEvent(void) { return (long) SDL_PollEvent; }
                                           ^
  gcc -Wl,--nxcompat,--dynamicbase -Wl,--high-entropy-va -Wl,--as-needed -Wl,--image-base,0x140000000 -Dmain=SDL_main -IC:/msys/include/SDL2 -mwindows -LC:/msys/lib -o /tmp/ffconf.atBoPojc/test.exe /tmp/ffconf.atBoPojc/test.o -lmingw32 -lSDL2main -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2main.a when searching for -lSDL2main
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib\libSDL2main.a when searching for -lSDL2main
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2main.a when searching for -lSDL2main
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2.dll.a when searching for -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2.a when searching for -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib\libSDL2.a when searching for -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2.dll.a when searching for -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/msys/lib/libSDL2.a when searching for -lSDL2
  c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2
  collect2.exe: error: ld returned 1 exit status
  </code></pre>
  
  <p>Okay, I managed to compile. I removed the sdl libraries from <code>C:/msys/lib</code>, and added them to <code>C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\lib</code></p>