EXE file for SDL-based programs (VISUAL STUDIO 2013)

Was just wondering if anyone is familiar with Visual Studio 2013 and getting the exe file of the program. I’m just trying to show my mates my program so far. I looked around and read that people have suggested to build the program via release. When i release the program a whole list of errors concerning SDL dependencies occur. My main question is when i switch to release would i have to do all the setup again? Also, is this the best way to simply get an exe file that uses SDL (the exe file in Debug folder needs to find SDL.dll when i run it from there)?


Are you supplying all the SDL DLL’s with the executable ?

Thats right

Sounds like your pathing is incorrect.

If you just have “image.png” then “image” should be in the same directory as the executable. If its “Media/” then your images should be in “Media”, which in turn should be in the same place as your executable.

If however, you are using fixed paths (“C:\moo\blah”), then you are being very naughty and need to change that as soon as possible.

You could load all data from a resource, but, unfortunately that sort of thing is a Windows-only feature.

Stupid question: you’re sending them the data in a ZIP file, right?
Did you make sure they actually extracted the files and didn’t run the
EXE directly? I know this sounds stupid but Windows makes it really
easy to forget (since it opens ZIP files as if they were folders, even
though programs can’t use them as such)

2014-10-13 10:01 GMT-03:00, MrTAToad :

If you just have “image.png” then “image” should be in the same directory as
the executable. If its “Media/” then your images should be in “Media”,
which in turn should be in the same place as your executable.

Beware that this won’t work if the current directory isn’t the same as
the executable directory (this is the reason why SDL_GetBasePath

Do you mean having all the SDL’s DLLs being in the same directory?

I pasted all the DLL which i was using (in the same folder as the .vcxproj) into the debug folder. It runs the program (yay!) but then the images wouldn’t appear. Does this mean i’d need to change the code to show others? I thought there might be a way just to “compress” everything into 1 .exe file.

Thanks for the quick reply!

Right now my images are stored in “Resource Files” (folder i created) which is in the same directory as the .vcprojx file. When i move the “Resource files” folder into the directory of the .exe (/Debug) i’m just struggling with typing the syntax. I tried “Debug/Resource Files/image.png” but that ain’t working. Is it possible to provide me with an example on how to type the directory? Code is fine it’s just me typing the directory incorrectly.

It may be easier to provide the loading part of your code, to see if there is anything wrong with it (like an extra space or something).

This is based off LazyFoo’s. The current code works fine.


SDL_Texture *loadTexture(std::string path)
SDL_Texture *newTexture = NULL;

SDL_Surface *loadedSurface = IMG_Load(path.c_str());

if (loadedSurface == NULL)
	std::cout << "Failed loading image" << std::endl;

	newTexture = SDL_CreateTextureFromSurface(gRenderer, loadedSurface);

	if (newTexture == NULL)
		std::cout << "Unable to create texture" << std::endl;

	//	Remove old loaded surface
return newTexture;



bool loadMedia()
// Loading success flag
bool success = true;

    // Debug Folder... gImage1 = loadTexture("Debug/Resource Files/Image1.png");
gImage1 = loadTexture("Resource Files/Image1.png");
if (gKanye == NULL)
	std::cout << "Unable to load image1!" << std::endl;
	success = false;

    // Debug Folder... gImage2 = loadTexture("Debug/Resource Files/Image2.png");
gImage2 = loadTexture("Resource Files/Image2.png");
if (gSubRegion == NULL)
	std::cout << "Unable to load image2!" << std::endl;
	success = false;

return success;


I’m not quite sure how to move up 1 folder from the .vcprojx directory and into the debug folder. That might be an issue…Not sure. I just commented out what i attempted (but failed)

That should be fine - have you tried copying Resource Files into the Release directory, in case you are compiling for release mode.