Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Texture.loadFromFile() accessing invalid memory location  (Read 1741 times)

0 Members and 1 Guest are viewing this topic.

RedstonerKBC

  • Newbie
  • *
  • Posts: 3
    • View Profile
Texture.loadFromFile() accessing invalid memory location
« 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.

RedstonerKBC

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Texture.loadFromFile() accessing invalid memory location
« Reply #1 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?

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Texture.loadFromFile() accessing invalid memory location
« Reply #2 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.

 

anything