Public Group

# IMG_Load - fails in debugger, succeeds without [SOLVED]

This topic is 4373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[EDIT]: Solved, it all boiled down to a simple, stupid, wrong working directory Original Message: ------------------------------------------------------------------------------- Hey, I think the topic title must have explained a lot already, but I'll re-explain anyway [grin]. Somehow, when I run the debug version with the Visual C++ debugger, the IMG_Load function from SDL_image won't work. All the surfaces that are loaded with it remain NULL pointers. The strange thing is, however, that as soon as I simply open the folder in which the .exe is located and double click on the application from there, it works fine, no problems at all. All images are displayed exactly as they should as well. Is there anyone who has a clue about what might be the underlying cause of this (I don't know my IDE well enough, it seems)? Normally I wouldn't bother debugging, but there's something else I need to debug in the application, and this image loading thing in debug mode prevents that. Underneath is my image loading method:
SDL_Surface * LoadImage ( std::string filename )
{
SDL_Surface *temp1 = NULL;
SDL_Surface *temp2 = NULL;

temp1 = IMG_Load ( filename.c_str() );

if ( temp1 != NULL )
{
temp2 = SDL_DisplayFormat ( temp1 );
SDL_FreeSurface ( temp1 );
}

return temp2;
}


Thanks in advance for any help. - Rogier [Edited by - rogierpennink on October 1, 2006 2:33:44 PM]

##### Share on other sites
Maybe working directory in debugger settings in project properties points to wrong directory?

##### Share on other sites
On your suggestion I explicitly set the working directory to the Debug folder of the project, however, the images still won't load when debugging. (The images are in "media/images/", relative to the debug folder). Does the debugger require me to put all image files in the same directory or something?

Edit: I actually did that and it didn't work either :(

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
16
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632593
• Total Posts
3007271

×