SFML 不启动窗口

SFML doesn't launch window

本文关键字:窗口 启动 SFML      更新时间:2023-10-16

我刚开始进行2D视频游戏编程,我决定使用Eclipse,因为我已经习惯了在Java开发中使用Eclipse。我还决定使用SFML,并为Eclipse安装了C/c++工具,并使用MinGW作为GCC编译器。我在外部库链接和包含方面遇到了很多麻烦,但它假设已经修复了,因为我在编译时没有错误消息。
现在,当我尝试编译和执行像这样的任何代码时(它们都直接取自SFML教程):

#include <SFML/Graphics.hpp>
int main()
{
// create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
// run the program as long as the window is open
while (window.isOpen())
{
    // check all the window's events that were triggered since the last iteration of the loop
    sf::Event event;
    while (window.pollEvent(event))
    {
        // "close requested" event: we close the window
        if (event.type == sf::Event::Closed)
            window.close();
    }
    // clear the window with black color
    window.clear(sf::Color::Black);
    // draw everything here...
    // window.draw(...);
    // end the current frame
    window.display();
}
return 0;
}

发生任何事情,它应该启动一个空窗口…
Eclipse的配置在教程中没有明确说明,所以我做的库配置是这样的,我检查了:

  • C:MinGWbin添加到项目环境PATH。

  • Project Properties> C/c++ Build> Settings> MinGW c++ Linker> Libraries,从需要的库开始,直到不需要的库,如教程所解释的(sfml-graphics, sfml-window, sfml-system)。也尝试了sfml-xxx-d库,仍然不起作用。

  • Project Properties> C/c++ Build> Tool Chain Editor> Current builder = Gnu make builder。

  • 运行配置>参数>程序参数:-SFML_DYNAMIC

我在4个多小时的时间里一直在试图解决这个问题,所以我需要帮助,否则我会发疯的…谢谢大家。

我没有解释,但我有同样的问题与"调试"库链接。我可以通过在"调试"模式下启动应用程序来使其工作。