Load a Texture

Hello OpenGL communauty,

I have a big problem with IMG_Load function from “SDL_image.h”.

I have an image called underground.png and when I’m loading it, I’m permanently get the error : “IMG_Load : Failed loading libjpeg-9.dll specified is unfoundable”.

This is strange because the file exist, as I you can see in my output. I also correctly linked my libraries, I have pain to understand why, IMG_Load is not able to load my images.

In this function I’m showing the folders of my current directory and I’m make an image load of each folder, if it work it write “worked” else it print an error message.

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <GL\glut.h>

#include <iostream>
#include <string>
#include <cstdlib>

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

void			displayDirectory(std::string path)
{
	SDL_Surface*	img		= nullptr;
	struct dirent*	lecture;
	DIR*		rep;

	rep = opendir(path.c_str());
	std::cout << "repository name : " << path.c_str() << "

";
	while ((lecture = readdir(rep)))
	{
		std::string		imagePath = path + "/" + lecture->d_name;

		std::cout << lecture->d_name << std::endl << imagePath << std::endl;

		if (nullptr == (img = IMG_Load(imagePath.c_str())))		std::cout << "IMG_Load:" << IMG_GetError () << std::endl; 
		else								std::cout << "worked
";
	}

	while (42) std::cout << "";
	//std::cout << std::endl;
	closedir(rep);
}}

output :
[ATTACH=CONFIG]1369[/ATTACH]

I posted a possible answer to your problem over here. Please do not cross post.

Thanks you for this answer, it don’t work yet, but I have a different error. I found this dll on a github project but now I have the following error :
“IMG_Load : Failed loading libpng16-16.dll”
I already put in my visual directory :
libjpeg-9.dll
libpng16-16.dll
libtiff-5.dll
libwebp-4.dll

Those libraries have to be in the same directory as the application binary.

My libraries are in the same folder than my application binary. I’m asking what should I do of more

Linking involves finding dll files (dynamic linked libraries) from specific linker paths you specify during compilation.

Post your linker flags, linker paths and the rest of your compile options. That will help figuring out what is going on.

I see you’re using .dll’s so I’m assuming you are using Visual Studio, or are you using something else (GCC?)?

Hello MtRoad,

Yes I’m using Visual studio, I’m not using an other compiler (like GCC).

Here my linkers flags :
opengl32.lib
glut32.lib
SDL2.lib
SDL2main.lib
SDL2_image.lib