SFML(32位VS12) - SFML.exe中0x701ADEF8(msvcr110.dll)中的未处理异常:0xC0000005:访问冲突读取位置0x0526。 LoadFromFile [英] SFML (32-bit VS12) - Unhandled exception at 0x701ADEF8 (msvcr110.dll) in SFML.exe: 0xC0000005: Access violation reading location 0x0526. LoadFromFile

查看:295
本文介绍了SFML(32位VS12) - SFML.exe中0x701ADEF8(msvcr110.dll)中的未处理异常:0xC0000005:访问冲突读取位置0x0526。 LoadFromFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码为我提供未捕获的异常(特别是

The following code gives me the uncaught exception (specifically

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

):未处理SFML.exe中的0x701ADEF8(msvcr110.dll)异常:0xC0000005:访问冲突读取位置0x05260000。

): "Unhandled exception at 0x701ADEF8 (msvcr110.dll) in SFML.exe: 0xC0000005: Access violation reading location 0x05260000."

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;
}

  程序,一堆随机ASCII字符输出到控制台(有时甚至个人文件,如论文等)。然后,控制台变为空白(空字符),并抛出异常。

     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.

     一次,我能够暂停程序并且向上滚动它说:无法打开文件'chessboard.gif(在字中有一些随机的ASCII字符'),然后长ASCII字符列表。

     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.

      SFML有什么问题或我做错了什么?我知道SFML文档说有时文件可能不加载和抛出异常,但在这种情况下,它是疯了。此外,我随机放置一个不存在的文件名,仍然发生相同的事情,而不是抛出一个文件未找到异常。

     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.

     我已经在Orwell Dev-C ++上尝试过相同的代码,它只是返回一个白色框,其中的图像应该是,并且当该文件不存在时返回一个异常。

     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.

一些图片:

http://i.stack.imgur。 com / gq420.png

http://i.stack .imgur.com / Os8jw.png

     我将很乐意提供任何额外的信息。

     I will be glad to provide any extra information.

谢谢

   Usandfriends!

Thank you,
  Usandfriends!

推荐答案

当您将调试库与发布模式或发布库与调试模式混合时,会出现此问题。确保在调试模式下仅使用 -d 后缀SFML库,而在释放模式下使用非后缀SFML库 - 如官方教学

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.

另外,建议您总是使用 int main()。如果你只想要一个没有命令提示符的窗口,那么你可以将子系统改为窗口并链接 sfml-main

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.

这篇关于SFML(32位VS12) - SFML.exe中0x701ADEF8(msvcr110.dll)中的未处理异常:0xC0000005:访问冲突读取位置0x0526。 LoadFromFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆