gpt4 book ai didi

c++ - SFML 库 : strange error

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:30:53 24 4
gpt4 key购买 nike

我正在学习 SFML 库,我从教程中选择了一个代码。它打开一个窗口,它应该让我能够再次关闭它但是当我关闭它时它说

Debug Error!
Run-Time Check Failure #2 - stack around variable 'App' was corrupted.

and then the console stops working.
this is my code:

int main()
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Events");

while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();

// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}

// Display window on screen
App.Display();
}

return EXIT_SUCCESS;// = return 0
}

链接到调试库是

sfml-system.lib
sfml-window.lib
sfml-system-d.lib//these are debug files
sfml-window-d.lib

如果我移动前 2 个并构建我的程序它不会给出错误但是当我打开它时它说:

the application was unable to start correctly (0xc0150002). click ok to close the application

我有一台 64 位计算机。在 Microsoft vc++ 2010 中,我可以构建解决方案或调试,而且我总是构建解决方案。

我正在以 Release模式构建,但我也都尝试过,但都没有用

有人可以告诉我我可以做些什么来防止这种情况发生或者这是怎么发生的。

最佳答案

对于这些应用程序启动问题,检查依赖闭包中的所有 dll 是否都可访问始终是一个好主意——也就是说,它们是否都在搜索路径中?我们通常使用dependency walker检查缺少哪些 dll,或使用 gflags用于运行时诊断

虽然将您的 dll 与您的 exe 放在同一个文件夹中是可行的,但它不能很好地扩展,我通常做的一种方法是将库路径放在 PATH 环境变量中。

需要注意的一件事是,sfml 带有预构建的 vs2005 和 vs2008 二进制文件,因为您使用的是 vs2010,底层的 c 运行时库 (msvcrt) 不同,可能会有潜在问题 - 您最好自己从源代码构建 sfml使用vs2010还是使用vs2005/vs2008,只是为了保持一致

关于c++ - SFML 库 : strange error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12352589/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com