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

Author Topic: LoadFromFile() hates me.  (Read 14103 times)

0 Members and 4 Guests are viewing this topic.

Xavura

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
LoadFromFile() hates me.
« Reply #15 on: February 18, 2009, 05:21:16 pm »
Quote from: "Tank"
Quote from: "Xavura"
The debugger is pointing to the line with the call to LoadFromFile() (only when using an absolute path).

Maybe a dumb question, but are you escaping the \ characters (if used at all)?

:shock:

Like... double backslashes?

No. :x Please don't tell me that's the problem...

I'll try now.

EDIT:

Doesn't make a difference:

Code: [Select]

// ...

if (grassImage.LoadFromFile("C:\\Documents and Settings\\Xavura\\My Documents\\Visual Studio 2008\\Projects\\SMFLTest\\grass.bmp")) {
cout << "Worked." << endl;
}
else {
cout << "Didn't work." << endl;
}

// ...


Code: [Select]

Unhandled exception at 0x102565af in SMFLTest.exe: 0xC0000005: Access violation reading location 0xcccccccc.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
LoadFromFile() hates me.
« Reply #16 on: February 18, 2009, 05:23:19 pm »
Yeah, exactly. "C:\blah.bmp" must be "C:\\blah.bmp". Please turn on your compiler warning completely. It should tell you that you've used an unknown escape sequence -- at least in the most cases. When using "C:\n..." or "C:\t..." or something else that's really defined, you're trapped. :P

I recommend to use slahes instead of backslashes. They work flawlessly on Windows, too.

Edit: Are you linking to the correct libraries? When building your program in debug mode, you have to use the debug libraries of SFML. (sfml-graphics-d.lib etc.). Are you linking dynamically? Then please define the SFML_DYNAMIC preprocessor macro.

Xavura

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
LoadFromFile() hates me.
« Reply #17 on: February 18, 2009, 05:28:35 pm »
In Project Properties > Configuration > Linker > Input > Additional Dependencies I have:

Code: [Select]

sfml-window-s.lib
sfml-graphics-s.lib
sfml-system-s.lib
sfml-audio-s.lib


EDIT:

I've tried changing them to the -s-d.lib variants and I get a LOT of errors. Changing them to the variants without suffixes also generates errors.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
LoadFromFile() hates me.
« Reply #18 on: February 18, 2009, 06:56:17 pm »
Without a suffix, you link dynamically and therefore need to #define SFML_DYNAMIC in your project properties.
If all of that doesn't work, I don't have a clue what's wrong.

Xavura

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
LoadFromFile() hates me.
« Reply #19 on: February 18, 2009, 07:09:51 pm »
I have defined SFML_DYNAMIC in Project Properties > Configuration > C/C++ > Preprocessor > Prepocessor Definitions.

Upon compiling I receive just one error:

Code: [Select]

mt.exe : general error c101008a: Failed to save the updated manifest to the file ".\Debug\SMFLTest.exe.embed.manifest". The parameter is incorrect.


Any ideas?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
LoadFromFile() hates me.
« Reply #20 on: February 18, 2009, 07:18:37 pm »
VC++2008 screwed up? ;) Sorry, I don't know, I don't use MSVC.

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
LoadFromFile() hates me.
« Reply #21 on: February 18, 2009, 07:47:59 pm »
have you tried running the exe on its own with the image in the same dir as the exe? sometimes, if its a path problem, it'll work.  I also recommend using slashes instead of backslashes.  

Also, if you're using SFML_DYNAMIC, then you dont need to link to the static libs right?  (so sfml-window-s.lib should just be sfml-window.lib).

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
LoadFromFile() hates me.
« Reply #22 on: February 18, 2009, 10:28:13 pm »
Quote from: "Tank"
Nah, importing namespaces is not comparible with defining variables. It's something that happens at compile-time, not run-time.
I think I know the difference. I also wrote "similar" instead of "exactly the same in every respect", and of course that was referred to the context I told it in. :roll:

As I already stated, the address 0xcccccccc may indicate an uninitialized variable. Maybe you link the wrong libraries of SFML or the wrong CRT configuration. By the way, did you try rebuilding the solution (concerning your manifest error)?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
LoadFromFile() hates me.
« Reply #23 on: February 19, 2009, 03:11:24 am »
Quote from: "Nexus"
I think I know the difference. I also wrote "similar" instead of "exactly the same in every respect", and of course that was referred to the context I told it in. :roll:

Of course you know the difference. My post shouldn't mean that I think you don't. The only thing is that even in that context, it was misleading. Local variables make sense, everytime. Now imagine you import namespaces everytime locally in functions. Do you think the compiler would like that, since it means shitloads of extra-work? ;)
Whatever, I guess we all agree that importing namespaces is a big no-no. Could be compared with using global variables. ;)

Bmuig

  • Newbie
  • *
  • Posts: 1
    • View Profile
LoadFromFile() hates me.
« Reply #24 on: February 23, 2009, 01:52:04 pm »
Hi,

just wanted to let you know that I have exactly the same problem with LoadFromFile(). The interesting thing is that the programm compiles perfectly fine and the errror occours only at runtime (even when I run the most basic tutorial program LoadFromfile() crashes). Everything else works normally ....

The problem can't be that LoadFromFile() doesn't find the image, since then it would just return false and not crash the whole compiler.

I'm pretty sure that the problems started when I switched from VS2003 to VS2005, but that might be just an coincidense.

Realy hope somebody can help....    :cry:

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
LoadFromFile() hates me.
« Reply #25 on: February 23, 2009, 02:06:45 pm »
It seems to be a problem with VC then. I would just encourage you to use another (better? ;)) compiler, but that's maybe not what you want to hear. :) Can you create a ZIP containing a minimal example, including an image?