I’ve been trying to develop a quick game with SDL2, and since I’ve done this exact thing with SDL2 (2.26.2). I figured this would be a walk in the park except one error has been driving me completely mad and insane.
Since I had a simple code base using SDL2 and I didn’t want re-write everything I just mostly write the exact same thing. I used to use Windows but then transitioned to Linux (PS I’ve tried this with MinGW on Windows and I get the exact same error).
So basically I noticed that my SDL Image wasn’t loading. To be clear I’ve made sure about everything, on Linux I’ve recompiled it from scratch with no errors and also used the apt-get (no difference), on Windows I’ve made sure to put in the libpng16 and zlib dlls, etc.
But it would error out with the error in the title.
Eventually I traced every thing down to the start of my file.
Here is a quick example.
int main(int argc, char** argv){
sW = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
SDL_UpdateWindowSurface(sW);
// this returns the error in the title.
printf("%s\n", SDL_GetError());
// ... Other code for SDL renderer and stuff
}
I had an issue on github and I was told not to call SDL_UpdateWindowSurface which caused my program to segfault when I used SDL_GetWindowSurface. And whether or not I should call it, it didn’t fix the problem, and as I said: that was in my other game that ran just fine.
I will be willing to give more details about compiler commands and files if needed, and any help would be appreciated.
The only thing that has really changed between then and now is I’m using MinGW-w64 instead of the base MinGW (and also SDL version). I can’t really test my old game code right now as it needs all the new libraries and stuff to recompile it using MinGW-w64, though if I have to then I will try to.
This error has been driving me insane and no other fixes for similar issues have worked here.
Also sorry if my formatting is terrible, I just want this fixed.