mingwのSDLをcygwinから使う

特に問題なくできるみたいだ。

こういうファイルを用意して

#include <stdio.h>
#include <SDL.h>

int main(int ac, char** av)
{
    if (SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        fprintf(stderr, "can't init SDL\n");
    }

    if (!SDL_SetVideoMode(640, 480, 32, SDL_ANYFORMAT))
    {
        fprintf(stderr, "can't set video mode\n");
    }

    SDL_Quit();

    return 0;
}

こうする

gcc -c cygwinsample.c -I/usr/include/mingw/SDL
gcc -o cygwinsample cygwinsample.o -L/usr/lib/mingw -lmingw32 -lSDLmain -lSDL

実行すると一瞬画面がでてるからたぶんうまくいってる。

cygcheck の結果がこれ

.\cygwinsample.exe
  C:\cygwin\bin\cygwin1.dll
    C:\WINDOWS\system32\ADVAPI32.DLL
      C:\WINDOWS\system32\KERNEL32.dll
        C:\WINDOWS\system32\ntdll.dll
      C:\WINDOWS\system32\RPCRT4.dll
        C:\WINDOWS\system32\Secur32.dll
  C:\cygwin\lib\bin\SDL.dll
    C:\WINDOWS\system32\msvcrt.dll
    C:\WINDOWS\system32\GDI32.dll
      C:\WINDOWS\system32\USER32.dll
    C:\WINDOWS\system32\WINMM.DLL

というわけで、

  • -I/usr/include/mingw しない
  • -Dmain=SDL_main しない
  • -mno-cygwin -mwindows しない

コンパイルとリンクをすればmingwなDLL自体はcygwinなexeからよろしく使えそうな気配。