0x5401FA96处未处理的异常(sfml-system-d-2.dll)

时间:2015-07-24 00:06:27

标签: c++ visual-studio sfml

我正在尝试使用SFML创建一个简单的程序。源代码与此example

中提供的内容相同

鉴于我使用Visual Studio 12中的预编译版本从站点下载了SFML。

我正常配置了项目,并为调试和发布添加了正确的库。

注意:

没有编译器错误,也没有链接器错误。我还在.exe目录中添加了.dll库。

当我运行程序时,这是输出(只是崩溃):

Exception thrown at 0x50FAFA96 (sfml-system-d-2.dll) in TestSFML.exe: 0xC0000005: Access violation reading location 0xCCCCCCD8.

If there is a handler for this exception, the program may be safely continued.

从我在互联网上看到的,这个错误似乎与混合调试和发布库有关,但我认为我做得对。

请注意,我使用的是 Visual Studio Community 2015 ,但我认为这不会导致问题。

项目内的配置

发布和调试(所有配置)

为包含路径(发布和调试)和库路径(发布和调试)添加了相同的目录。

版本

Linker -> Input我添加了:

sfml-window.lib
sfml-system.lib

调试

Linker->Input我添加了:

sfml-system-d.lib
sfml-window-d.lib

由于我使用的是动态库,我还在可执行文件的目录中添加了库。

修改

Main.cpp的

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>

int main()
{
    // create the window
    sf::Window window(sf::VideoMode(800, 600), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);

    // load resources, initialize the OpenGL states, ...

    // run the main loop
    bool running = true;
    while (running)
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        // clear the buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // draw...

        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    // release resources...

    return 0;
}

项目的附加依赖项。它们设置在Active(Debug)

opengl32.lib
sfml-system-d.lib
sfml-window-d.lib

汇编

1>------ Build started: Project: TestSFML, Configuration: Debug x64 ------
1>  main.cpp
1>  TestSFML.vcxproj -> C:\Users\Leonardo\documents\visual studio 2015\Projects\TestSFML\x64\Debug\TestSFML.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

1 个答案:

答案 0 :(得分:0)

在使用VS2015时尝试使用SFML for VS2013编译SFML程序时遇到了同样的错误。下载(显然使用)正确的版本解决了问题。

相关问题