0

I am running on a Debian 10 Bullseye Crostini VM on ChromeOS 111.0.5563.100. Here is my SDL2 code...

#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>

int main(int argc, char *argv[])
{
    bool rungame = true;

    if (!SDL_Init(SDL_INIT_VIDEO))
    {
        perror("Failed to initialize SDL");
        return -1;
    }
    
    SDL_Window *window = SDL_CreateWindow(
        "Dungeoneer",
        SDL_WINDOWPOS_UNDEFINED,
        SDL_WINDOWPOS_UNDEFINED,
        SCR_W,
        SCR_H,
        SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI
    );
    if (window == NULL)
    {
        perror("SDL Window failed to initialize");
        return 1;
    }

    SDL_Renderer *render = SDL_CreateRenderer(
        window,
        -1,
        SDL_RENDERER_ACCELERATED
    );
    if (render == NULL)
    {
        perror("SDL Renderer failed to initialize");
        return 2;
    }

    SDL_Event event;
    while (rungame)
    {
        SDL_SetRenderDrawColor(render, 0, 0, 0, 255);
        SDL_RenderClear(render);
        
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
                case SDL_QUIT:
                    return 0;
                    break;
            }
        }

        SDL_RenderPresent(render);
    }

    return 0;
}

I am not getting any compilation errors or warnings. But when I execute the returned binary file that I receive with this command...

g++ main.cpp -o main.out -Wall -lm -lSDL2

I get this result...

Failed to initialize SDL: Resource temporarily unavailable

What is interesting is that PyGame runs without any issue at all. I tried searching for any solution but I couldn't find anyone who has experienced a similar issue that I could derive a viable solution from.

genpfault
  • 51,148
  • 11
  • 85
  • 139
TheEngineerGuy
  • 208
  • 2
  • 8

1 Answers1

0

After some more research, I found the solution.

sudo apt install xorg-dev

From what I found, SDL2 requires this library in order to be developed. Crostini uses a x11 window server to run Linux GUI applications, so this makes sense that you would need the development package.

TheEngineerGuy
  • 208
  • 2
  • 8