'SDL_image failing to initialise

When I try and initialise IMG or use IMG_Load, I get the error:

"IMG_Init: Failed loading libpng16-16.dll: The specified module could not be found."

From what I can tell, this should only happen if I forget to put the dll in the same directory as the main.cpp file. But it is already in that folder. I'm using visual studio so I'm not sure if that makes a difference as to where the file needs to be.

Here's the code I'm using to initialise :

if (SDL_Init(SDL_INIT_VIDEO < 0)) {
    printf("SDL_Init: %s\n", SDL_GetError());

};

int flags = IMG_INIT_JPG | IMG_INIT_PNG;
int initted = IMG_Init(flags);
if ((initted & flags) != flags) {
    printf("IMG_Init: %s\n", IMG_GetError());
    
};

if (TTF_Init() == -1) {
    printf("TTF_Init: %s\n", TTF_GetError());

};

Also just encase it helps, here's a list of the files I included in the main directory, encase I've missed one.

  • SDL2.dll
  • SDL2_image.dll
  • libjpeg-9.dll
  • libpng16-16.dll
  • libtiff-5.dll
  • libwebp-7.dll
  • zlib1.dll

Update: I've tried moving the dlls and image file into any directory I can think of and nothing is working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source