SDL Doesn't Display Image C++ Ubuntu Linux

No it does not work if I load another picture none work.
Yes it is totally fine in other programs.
mainMenuBackground copy.zip (707.8 KB)

In that case there seems to be nothing wrong with the file itself. It loads correctly for me.

I’m curious about the error message that you got. Was it really “Unsupported file type” or was it “Unsupported image format”?

I noticed that the file name is not the same as in the code you posted but I take it you have it correct in your code.

I must’ve misread it, it is unsupported file format!

I have no idea where that error message come from. I cannot find it when searching the SDL, SDL_image, libpng and stb_image code bases. I don’t know what more to try, sorry…

Yeah I’m sorry you wasted your time, thank you for trying though!

I think this is it! Great job guys, a google search on that error returned this:
In your compiler commands you have -lSDL_image when it needs to be -lSDL2_image.

That should do it.

2 Likes

THANK YOU SO MUCH! THIS WORKED!

It’s my own fault. :wink: no need to apologize.

Good find! It’s not the sort of thing I look for because I expect it to generate a linking error but I guess it doesn’t because the interface is still (mostly) the same in SDL2_image as it was in SDL_image. I should not be surprised though because I have run into similar problems with SDL_mixer vs. SDL2_mixer in the past where it loaded the sound but played it at the wrong rate.

Oh, that was so frustrating, glad it’s resolved.

To Leondagreatest: Just to double check, did you also fix the memory leak, because that is a big problem especially with a larger image file.

I think? I added SDL_FreeSurface and SDL_DestroyTexture

1 Like