SFML (WIN 32-Bit VS2012) Unhandled exception at 0x701ADEF8 .... sf::Sprite.loadFromFile(std::string filename);

closed account (18hRX9L8)
The following code gives me the uncaught exception (specifically line 6):
Unhandled exception at 0x701ADEF8 (msvcr110.dll) in SFML.exe: 0xC0000005: Access violation reading location 0x05260000.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int _tmain(int argc, wchar_t* argv[]) {
    sf::RenderWindow window(sf::VideoMode(512, 512), "ChessPlusPlus", sf::Style::Close);
    sf::Sprite chessboard;
    sf::Texture txtr;

    txtr.loadFromFile("C:/Users/kidz/Documents/Visual Studio 2012/Projects/SFML/Debug/chessboard.gif");
    chessboard.setTexture(txtr);

    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }

        window.clear();
        window.draw(chessboard);
        window.display();
    }

    getwchar();
    return 0;
}


Also, during the debugging of the program, a bunch of random ASCII characters get outputted onto the console (sometimes even personal files like essays, etc...). Then, the console goes blank (null characters) and the exception is thrown.

Once, I was able to pause the program and scroll all the way up at it said something like: "Unable to open file 'chessboard.gif (with some random ASCII characters in the word)'" and then the long list of ASCII characters.

Is there something wrong with SFML or am I doing something wrong? I know that SFML docs say that sometimes the file may not load and throw a exception, but in this case, it's going crazy. Also, I have randomly put a filename that does not exist and the same thing still occurred instead of throwing a file not found exception.

I have tried the same code on Orwell Dev-C++ and it just returns a white box where the image is supposed to be and returns an exception when the file does not exist.

Some pictures:
http://i.stack.imgur.com/gq420.png
http://i.stack.imgur.com/Os8jw.png

I will be glad to provide any extra information.

Thank you,
Usandfriends!
Did you compile SFML yourself? Are you linking with debug libraries in release mode or release libraries in debug mode?
closed account (18hRX9L8)
No I did not compile the SFML myself. I just downloaded it from this link: http://www.sfml-dev.org/download/sfml/2.1/SFML-2.1-windows-vc11-32bits.zip and put everything in the correct directories.

Umm, not sure if this helps, but here are my additional dependencies (project options->configuration properties->linker->input->additional dependencies): sfml-main.lib, sfml-audio.lib, sfml-graphics.lib, sfml-network.lib, sfml-system.lib, sfml-window.lib.

Also, not sure if this helps, but the dlls in my executable path are: libsndfile-1.dll, openal32.dll, sfml-audio-2.dll, sfml-graphics-2.dll, sfml-network-2.dll, sfml-system-2.dll, sfml-window-2.dll.
closed account (18hRX9L8)
Found the answer:

StackOverflow wrote:
This issue arises when you're mixing debug libraries with release mode or release libraries with debug mode. Make sure to only use -d suffixed SFML libraries when in debug mode and non suffixed SFML libraries when in release mode - as stated in the official tutorial.

As a side note, it's also recommended to always use int main(). If you just want a window without the command prompt, then you can change the subsystem to window and link against sfml-main.

http://stackoverflow.com/questions/20208292/sfml-32-bit-vs12-unhandled-exception-at-0x701adef8-msvcr110-dll-in-sfml-ex#answer-20215509

Thank you cire for your time.
Last edited on
Topic archived. No new replies allowed.