0

I am running this in windows, compiled using cygwin and mingw.

Compile Command:

g++ sdl.cpp -I"include" -L"lib" -lSDL2main -lSDL2 -lSDL2_image -o test.exe

Code:

#include <SDL2/SDL.h>
int main(int argc, char *argv[])
{
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("error initializing SDL: %s\n", SDL_GetError());
    }
    SDL_Window*win = SDL_CreateWindow("Test",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,1000, 1000, 0);
    while (1);
    return 0;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
  • https://stackoverflow.com/a/14993480/920069 – Retired Ninja Jan 06 '22 at 03:53
  • 1
    Just don't use Cygwin? Programs compiled with the plain MinGW don't suffer from this (or you can use just a cygwin-based *shell* with mingw). I'm not sure if cygwin ships non-cygwin compilers, but there is [msys2](https://stackoverflow.com/q/30069830/2752075) does. – HolyBlackCat Jan 06 '22 at 07:18

1 Answers1

0

On Cygwin:

g++ sdl.cpp  -lSDL2main -lSDL2 -lSDL2_image -o test.exe 

Run the X server with startxwin, open a terminal and

./test.exe

A black window with a white bar appears.

As you put no handling of events, you need a hard kill to close the program

$ ps ax | grep test
    18455   18448   18455      25368  pty3      197609 12:39:35 /tmp/test

$ kill -9 18455
matzeri
  • 8,062
  • 2
  • 15
  • 16