0

I am trying to load PNG image, but it always ends in an error. I was first trying to use SDL's SDL_LoadBMP, but since that dind't work, I downloaded SDL2_image.h, did all the setup, but it still isn't working. The image is in the same directory as the cpp file. When I run my program, it runs, but prints error. Here is the function to load the image:

void loadImage()
{
    image = IMG_Load("Untitled.png");
    if (image == NULL)
        std::cout << "error: " << SDL_GetError();
}

The error message from SDL_GetError is Failed loading libpng16-16.dll: The specified module could not be found. I tried passing the full path, but it gives an error and I don't know how to get around that problem since I am a beginner. Thanks.

Edit: After reading through the article linked in the answer to the tagged-duplicate question and making some changes(particularly installing the missing dll file and putting it in the same directory as the main cpp flie), I am getting this error message in a pop-up window: The procedure entry point inflateValidate could not be located in the dynamic link library, and the path to libpng16-16.dll is given after that.

  • That DLL needs to be in one of the available environment `PATH`s when you run the program. Is it? – underscore_d Oct 02 '20 at 09:47
  • Does this answer your question? [SDL\_Image IMG\_Load fails on png with: "Failed loading libpng16-16.dll:"](https://stackoverflow.com/questions/21472958/sdl-image-img-load-fails-on-png-with-failed-loading-libpng16-16-dll) – underscore_d Oct 02 '20 at 09:48
  • Re-read the error message, it's explicitly giving you the name of the dll it's failing to find. – spectras Oct 02 '20 at 09:56
  • I just finished reading through the article linked in the answer to the tagged-duplicate question. Followed the steps, did everything it said, but now I am getting this error message in a pop-up screen: `The procedure entry point inflateValidate could not be located in the dynamic link library` –  Oct 02 '20 at 10:05
  • 1
    in what library? `zlib` presumably? then sounds like you have an older or newer DLL that lacks said function, right? – underscore_d Oct 02 '20 at 12:24

0 Answers0