未解析的外部符号:LNK 2001 [英] Unresolved External Symbol: LNK 2001

查看:67
本文介绍了未解析的外部符号:LNK 2001的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 NuGET 包管理器安装了 SFML 包.安装后.我从其官方页面运行了一个基本程序.只需复制和粘贴.

I just installed SFML packages using NuGET Package Manager. After installing it. I ran a basic program from its official page. Just copy and paste.

#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;
}

当我运行它时,我收到 LNK 2001 错误.说明未解析的外部符号.

When I run this i get LNK 2001 error. Stating Unresolved External Symbol.

我自己的尝试

我在谷歌上搜索,发现问题出在 lib 文件上.我在包文件夹中找到了文件,工具中没有列出它们,项目->属性.

I searched on google and found that the problem is it with the lib files. I found the files in the package folder, none of them are listed on the tools, Project->Properties.

尝试添加SFML_DYNAMIC,没有用;

Tried adding SFML_DYNAMIC, didn't work;

推荐答案

您需要向项目中的链接器依赖项添加适当的库.将库名称添加到 Project->Properties->Linker->Input->Additional Dependencies.

You need to add appropriate libs to linker dependencies in your project. Add library name(s) to Project->Properties->Linker->Input->Additional Dependencies.

这是关于配置 Visual Studio 项目的SFML 教程.

Here is SFML tutorial on configuring Visual Studio project.

这篇关于未解析的外部符号:LNK 2001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆