c++ - 未定义对 '__imp___..' SFML C++ 库的引用

标签 c++ sfml

我刚决定尝试了解 C++ 的 GUI 用户界面,发现 SFML 非常适合初学者。 我也使用 CodeBlocks 二进制版本(我猜) 我找到了一个教程,展示了如何将 SFML 库链接到代码块。 我完全按照它去做了。

拿了他们的示例程序,尝试构建它(编译得很好)

我得到了 20 个错误

enter image description here

这是代码:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

这些是我所做的更改:

enter image description here

我从来没有用过这些东西,我完全不知所措。 抱歉,这个问题可能不合适,但我还找不到任何相关的问题答案。

最佳答案

您需要在链接器设置中链接它 -lsfml-图形 -lsfml-窗口 -lsfml-系统

尝试在代码块中使用那些 undefined reference 通常是链接器错误

关于c++ - 未定义对 '__imp___..' SFML C++ 库的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28683814/

相关文章:

c++ - 编译器错误 : failed to bind overloaded function with two arguments

c++ - 我的 Visual C++ Win32 中有一个无法关闭的 MessageBox!到底是怎么回事?

c++ - 我如何在 C++ 中找到堆中的特定索引?

c++ - 非类型函数模板参数

c++ - 如何修复 "initial value of reference to non-const must be an lvalue?"

c++ - 在 VS2017 中使用 SFML 安装 CMake

c++ - Asp.Net Core Dependency Injection 不起作用,如果它是从非托管/ native 启动的

c++ - unique_ptr - 无效指针和段错误

c++ - 在 SFML 顶点数组中组合基元

c++ - 使用 sublime-build 时无法运行 C++ 程序,从终端运行时工作正常