SFML community forums

Help => Graphics => Topic started by: RedstonerKBC on August 18, 2019, 05:25:00 am

Title: Texture.loadFromFile() accessing invalid memory location
Post by: RedstonerKBC on August 18, 2019, 05:25:00 am
The docs say this code should return false if loading fails, but instead I get the following error:

#include <SFML/Graphics>

int main(){
sf::Texture tex;

if(!tex.loadFromFile("Player.png"))//exception thrown here
return -1;
}
 

Exception thrown at 0x564D334D (vcruntime140.dll) in My Project.exe:
0xC0000005: Access violation reading location 0x004C4000.
 

I'm using the .dll method as explained in the tutorials how to setup SFML for Visual Studio 2019. SFML version 2.5.1-x86.

When I comment out the line my game runs fine. If I pass it an empty string or put/remove the .png file from the working directory it still raises the exception.
Title: Re: Texture.loadFromFile() accessing invalid memory location
Post by: RedstonerKBC on August 19, 2019, 07:45:44 pm
Update: I switched to the Debug version of the libraries and now my code runs fine with no issues. I'm curious though, why? When should I use the debug vs non-debug libraries?
Title: Re: Texture.loadFromFile() accessing invalid memory location
Post by: G. on August 19, 2019, 08:14:06 pm
Use the debug libraries when you compile in debug mode and use the release libraries (the "non debug" ones) when compiling in release mode.