SDL2 window not showing up on Ubuntu

I am trying to make a simple blank window using SDL2 in C. Here is my code:

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>

#include <SDL2/SDL.h>

void manageEvents(bool* launched) {
    SDL_Event event;
    while (SDL_PollEvent(&event)) {
        switch (event.type) {
            case SDL_QUIT:
                *launched = false;


int main() {
    if(SDL_Init(SDL_INIT_VIDEO) < 0){
        printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
        return 1;

    SDL_Window* window = SDL_CreateWindow("Mandelbrot :)", 0, 0, 800, 600, SDL_WINDOW_SHOWN);
    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);

    if (window == NULL) {
        printf("No window pointer\n");
        return 1;
    bool launched = true;

    while (launched) {



    return 0;

When I compile my code, no errors show up. When I run it from the terminal, nothing happens and no window shows up. The while loop seems to run indefinitely, but it does run.

I am using Ubuntu 22.04.2 LTS and SDL 2.28.0.

I have installed SDL using the following commands:

sudo apt-get install libsdl2-2.0-0
sudo apt-get install libsdl2-dev

I have also tried compiling the source code myself by following the instructions on this page, with no success:

The window pointer is not NULL, I am sure.

Adding SDL_ShowWindow(window); before the while loop has not helped.

I tried adding this in my while loop, after the manageEvents(&launched); call:


Here is the command I use to compile it:

gcc ./main.c -o out -Wextra -Wall -Werror -lSDL2

It works here. The problem is neither your source code or your compile command. Maybe your window manager is putting the window somewhere you can’t see it? Do you have multiple monitors?

I’m also on Ubuntu 22.04.2 LTS.

No window seems to show up, I checked using alt + tab, and I only have one monitor. The window also doesn’t seem to show up on other desktops. I’m not sure how I could verify further that it actually doesn’t show up, but it doesn’t seem like it.