SFML community forums

Help => Graphics => Topic started by: Dummie on February 09, 2008, 03:48:20 pm

Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: Dummie on February 09, 2008, 03:48:20 pm
Hey guys,

I got a problem with the function LoadFromFile() of sf::Image...

When I'm trying to load a image I got a error in the console window "Failed [...] Reason : Unable to open file"...

I already tried to use other images and so on but it doesn't make any changes.

I'm using Visual Studio 2005 and Windows XP/SP 2 :)

The code compiles well so I guess there isn't a problem. Any solutions?

Thanks in advance,
Patrick

PS: I used this code: http://sfml.sourceforge.net/tutorials/sources/graphics-sprite.cpp

Edit: It seems I solved the problem with using the Release mode of Visual C++. And I also solved the problem with using sfml-system-d.lib etc. for Debug Mode. I now get some warnings in Debug mode but it works. Maybe you should mention this problem. All in all: Keep up the good work! I like SFML very much  :D
Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: Laurent on February 10, 2008, 07:14:42 am
It's written in the tutorials :

Quote
Open your project's options, then go to the Linker / Input item. In the Additional dependencies row, add the SFML libraries you are using. Here we only use sfml-system.lib. For the Debug configuration, you can link with the debug versions of the libraries, which have the "-d" suffix (sfml-system-d.lib in this case).
Title: LoadFromFile in Release mode in VC9
Post by: fixus971 on September 20, 2008, 08:08:14 pm
Hi Laurent. I love your SFML but lost many days to understand VC9 compiler option to make the Release version of a mini game that run perfectly in debug mode.
Now all compile well in Release version too but
I get and strange error derived from the fact that
Image.LoadFromFile fail! return false and width of image=0.
I verify directory in configuration and run from bin directory too.
What can I check?
How to check actual directory from program code?
Can be a lib that not work in release mode?
I use: SFML 1.3 in \lib\vc2008
I just try to restore in Release config all lib with -d at end but not get variations.
Any idea? thanks.
Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: eleinvisible on September 20, 2008, 10:18:22 pm
Are you sure the image is actually in your working directory?
Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: fixus971 on September 21, 2008, 11:10:08 am
yes, I retested in many modes (moving/renaming dir)
and comparing/testing with debug version that work.

Now, I want to test it in runtime..

How can I see, by program code, directory that SFML LoadFromFile use to find files?

Thanks
Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: Laurent on September 21, 2008, 11:11:02 am
Is there any message in the standard error output ?
Title: LoadFromFile() Problem:"[...] Reason : Unable to open f
Post by: fixus971 on September 21, 2008, 12:11:49 pm
Output win report this:
Code: [Select]

SILLY_d.dll', Il file binario non รจ stato compilato con le informazioni di debug.
<F>loadSprite: data/village.png  err.LoadFromFile==false  err.Width==0
^this from my internal debug code.


Now I found why SFML don't want to load images:
Code: [Select]

assert(  ok = aImage->LoadFromFile( ssFileName.str() )  );


In Release mode, code into assert isn't compiled at all.

Now my program load all ^_^ Thanks for patience.