I am using Manjaro linux and SDL 2. However, when I build the application in debug mode and use gdb or something like qtcreator with gdb, to debug it, it gives me a segfault, when the function SDL_Init()
is called.
The code I am trying this with:
#include <iostream>
#include <SDL2/SDL.h>
int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("SDL Init error: %s", SDL_GetError());
return -1;
}
SDL_Window *window = SDL_CreateWindow("window", 10, 120, 800, 640, 0);
SDL_Renderer *ren = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
bool running = true;
while (running)
{
SDL_Event e;
if (SDL_PollEvent(&e) != 0)
{
switch(e.type)
{
case(SDL_QUIT): running = false;
}
}
SDL_RenderClear(ren);
SDL_RenderPresent(ren);
}
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
I then recompiled SDL for debugging and went into the source, to find out this function in SDL.c is actually the cause:
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
if (SDL_VideoInit(NULL) < 0) { <- this here is causing the segfault
return (-1);
}
}
I don't know what to even do with this. None of the SDL versions work anymore. I've tried installing older ones, compiling from source.