SFML Displaying Sprite Error 0xC0000005: Access vi

2019-09-19 01:38发布

I wrote this code while following the tutorial for SFML in C++:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(600, 400), "Sandstorm");
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

        }
        window.clear(sf::Color::Black);
            sf::Texture back;
            if (!back.loadFromFile("greenBack.png"))
            return 1;
            sf::Sprite sprite;
            sprite.setTexture(back);
            window.draw(sprite);
        window.display();
    }
    return 0;
}

I kept on getting the same errors when I tried to run it. I might have done something wrong while setting the project up, I'm using Visual Studio 2012. I have the images and libraries in the same folder as my .exe and I keep on getting these errors:

First-chance exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. Unhandled exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. First-chance exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. Unhandled exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. First-chance exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. Unhandled exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. First-chance exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. Unhandled exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. First-chance exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. Unhandled exception at 0x695DDCF8 (msvcr110.dll) in Sandstorm.exe: 0xC0000005: Access violation reading location 0x00D54000. The thread 0x1858 has exited with code 0 (0x0). The program '[6616] Sandstorm.exe' has exited with code 0 (0x0).

if I go to msvrc110.ddl, it gives me errors here:

    rep     movsd           ;N - move all of our dwords

Can anyone help?

0条回答
登录 后发表回答