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

Author Topic: Trouble with loadFromFile  (Read 2152 times)

0 Members and 1 Guest are viewing this topic.

Aiden

  • Newbie
  • *
  • Posts: 2
    • View Profile
Trouble with loadFromFile
« on: December 04, 2013, 08:48:22 pm »
Hi everyone,

I know this question has been answered many times, but I'm still having trouble with getting my program to work correctly.
First the problem: I'm trying to load a texture from the disk into memory
sf::Texture texture;
texture.loadFromFile("image.png");
 

This should be relatively straight forward. However, I'm getting a crash as soon as I get to the second line. Along with the crash, my computer will sometimes beep a bunch, and print garbage to the standard output. If I'm lucky, I will see at the top of the console "Failed to load image 'image.png'", but the reason of failure is not displayed, and garbage is shown instead.


Example:



The directory I printed at the top of the console is just a test I wrote to make sure the current working directory is where I thought it was. I've made sure that the VS project has the working directory set to $(TargetDir) and I've made sure that the image is in the correct location.


In case it's relevant, I'm using Visual Studio 2012.


I've not been able to find a solution, so I hope you guys can help me.


Thanks a bunch!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Trouble with loadFromFile
« Reply #1 on: December 04, 2013, 08:59:14 pm »
Make sure that everything is linked correctly. Between SFML and your project, don't mix any configurations: compiler versions, debug <-> release mode, other compiler flags. Follow the official tutorial exactly, reread it step by step.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Aiden

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Trouble with loadFromFile
« Reply #2 on: December 04, 2013, 10:06:20 pm »
So I reread the tutorial, and sure enough, I had added both the debug and release DLLs to the linker's additional dependencies. I assumed I could add both, and it would work out which one was needed, but I guess not.

So when would I use the non-debug DLLs for the linker? When I want to compile in Release Configuration?

Thanks for the help!!
« Last Edit: December 04, 2013, 10:08:32 pm by Aiden »

KarmaKilledtheCat

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Trouble with loadFromFile
« Reply #3 on: December 10, 2013, 04:02:23 am »
Use the debug dlls when you are compiling the project on debug mode. Use the release dlls when you are compiling the project for being released.