Load a Texture With SDL

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]686[/ATTACH]

It’s not the image file that is missing, it is probably libjpeg-9.dll