【问题标题】:SFML doesn't launch windowSFML 不启动窗口
【发布时间】:2014-08-12 08:45:59
【问题描述】:

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

#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 的配置在教程中没有明确处理,所以我做的库配置是this,我检查了:

  • C:\MinGW\bin 添加到项目环境 PATH。

  • 项目属性 > C/C++ 构建 > 设置 > MinGW C++ 链接器 > 库,从需要其他库的库中订购,直到不需要的库,如教程所述(sfml-graphics、sfml-window、 sfml 系统)。也尝试使用 sfml-xxx-d 库,仍然无法正常工作。

  • 项目属性 > C/C++ 构建 > 工具链编辑器 > 当前构建器 = Gnu make Builder。

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

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

【问题讨论】:

    标签: c++ eclipse mingw sfml


    【解决方案1】:

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

    【讨论】:

    • 我终于放弃了 SFML。现在我正在使用 Cocos2d-x,它到目前为止更容易。还是谢谢你!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 2013-12-11
    • 1970-01-01
    • 1970-01-01
    • 2013-06-06
    • 2016-01-06
    • 2012-12-13
    相关资源
    最近更新 更多