SDL_Image IMG_Load error in png with: "Error loading libpng16-16.dll:"

Whenever I try to load PNG using the SDL_Image IMG_Load function, it gives a Failed loading libpng16-16.dll: error. I have all the right DLLs in the right way, and I can use other parts of SDL_Image, but for some reason it cannot load the libpng DLL. How can i fix this? Any help is appreciated.

+6
source share
4 answers

See my article " SDL2: Downloading Images Using SDL_image ":

If you intend to start from Visual Studio, make sure that the image is in the same folder as the main.cpp file; otherwise, if you are running directly from the executable file, the image should be in the same folder with it.

Needless to say, I wrote about this image for a DLL.

+4
source

It appears that libpng16-16.dll has a dependency on zlib1.dll for MinGW-w64 (32-bit). Try to include zlib in your dependencies - include the DLL in the folder where the executable is running.

+8
source

VS does not look for a DLL anywhere except the executable, so you probably need to copy this DLL into the Debug / directory on the solution path.

0
source

This link shows you how to configure the SDL / libpng16-16.dll library to access acceess using compiler.exe (the last step right before the sample code)

yourProgram page proprety -> Creates an event-> post-build event

in my case I have to copy "C: \ Users \ MehdiB \ Desktop \ C Program \ Library \ SDL2-devel-2.0.4-VC \ SDL2-2.0.4 \ lib \ x86 \ SDL2.dll" "$ (OutDir ) SDL2.dll ";
copy "C: \ Users \ MehdiB \ Desktop \ C Program \ Library \ SDL2_image-devel-2.0.1-VC \ SDL2_image-2.0.1 \ lib \ x86 \ SDL2_image.dll" "$ (OutDir) SDL2_image.dll";
copy "C: \ Users \ MehdiB \ Desktop \ C Program \ Library \ dll \ libjpeg-9.dll" "$ (OutDir) libjpeg-9.dll"

here where you can get this dll

0
source

All Articles