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

Author Topic: LoadFromFile() Problem:"[...] Reason : Unable to open f  (Read 5867 times)

0 Members and 1 Guest are viewing this topic.

Dummie

  • Newbie
  • *
  • Posts: 25
    • View Profile
LoadFromFile() Problem:"[...] Reason : Unable to open f
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoadFromFile() Problem:"[...] Reason : Unable to open f
« Reply #1 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).
Laurent Gomila - SFML developer

fixus971

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • http://www.fixweb.it
LoadFromFile in Release mode in VC9
« Reply #2 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.
^_^=>Il calcolatore è straordinariamente veloce, accurato e stupido. Gli uomini sono incredibilmente lenti, imprecisi e creativi. L'insieme dei due costituisce una forza incalcolabile. (Albert Einstein)

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
LoadFromFile() Problem:"[...] Reason : Unable to open f
« Reply #3 on: September 20, 2008, 10:18:22 pm »
Are you sure the image is actually in your working directory?

fixus971

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • http://www.fixweb.it
LoadFromFile() Problem:"[...] Reason : Unable to open f
« Reply #4 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
^_^=>Il calcolatore è straordinariamente veloce, accurato e stupido. Gli uomini sono incredibilmente lenti, imprecisi e creativi. L'insieme dei due costituisce una forza incalcolabile. (Albert Einstein)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
LoadFromFile() Problem:"[...] Reason : Unable to open f
« Reply #5 on: September 21, 2008, 11:11:02 am »
Is there any message in the standard error output ?
Laurent Gomila - SFML developer

fixus971

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • http://www.fixweb.it
LoadFromFile() Problem:"[...] Reason : Unable to open f
« Reply #6 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.
^_^=>Il calcolatore è straordinariamente veloce, accurato e stupido. Gli uomini sono incredibilmente lenti, imprecisi e creativi. L'insieme dei due costituisce una forza incalcolabile. (Albert Einstein)