【问题标题】:C++ Visual Studio 2012 Linker Errors?C++ Visual Studio 2012 链接器错误?
【发布时间】:2013-12-27 06:48:37
【问题描述】:

我是 C++ 的新手,我正在使用 SFML 设置一个项目,该项目运行良好,根据 Visual Studio,我没有代码问题,但是当我调试时,我收到以下错误消息:

错误 1 ​​错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:__thiscall sf::String::String(char const *,class std::locale const &)" (_imp??0String@sf@@QAE@PBDABVlocale@std@@@Z) 在函数中引用 “公共:静态无效__cdecl游戏::开始(无效)” (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 2 错误 LNK2019:无法解析的外部符号 “__declspec(dllimport) public: _thiscall sf::String::~String(void)” (_imp_??1String@sf@@QAE@XZ) 在函数“public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 3 错误 LNK2019:无法解析的外部符号 “__declspec(dllimport) 公共:_thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (_imp_??0VideoMode@sf@@QAE@III@Z) 在函数“public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj 乒乓SFML

错误 4 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:无效 _thiscall sf::Window::create(类 sf::VideoMode,类 sf::String const &,unsigned int,struct sf::ContextSettings const &)" (_imp_?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z) 在函数“public:static void __cdecl Game::Start(void)”中引用 (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 5 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:无效 _thiscall sf::Window::close(void)" (_imp_?close@Window@sf@@QAEXXZ) 引用 在函数“公共:静态 void __cdecl Game::Start(void)”中 (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 6 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) public: bool _thiscall sf::Window::pollEvent(类 sf::Event &)" (_imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) 函数“私有:静态无效 __cdecl Game::GameLoop(void)” (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 7 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:无效 _thiscall sf::Window::display(void)" (_imp_?display@Window@sf@@QAEXXZ) 在函数“private: static void __cdecl”中引用 游戏::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 8 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) public: _thiscall sf::Color::Color(unsigned 字符,无符号字符,无符号字符,无符号字符)" (_imp_??0Color@sf@@QAE@EEEE@Z) 在函数“private: 静态 void __cdecl Game::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 9 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:无效 _thiscall sf::RenderTarget::clear(class sf::Color const &)" (_imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) 函数“私有:静态无效 __cdecl Game::GameLoop(void)” (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 10 错误 LNK2019:无法解析的外部符号 “__declspec(dllimport) 公共:_thiscall sf::RenderWindow::RenderWindow(void)" (_imp_??0RenderWindow@sf@@QAE@XZ) 在函数“void”中引用 __cdecl 'private: static class sf::RenderWindow Game::mainWindow''(void)'的动态初始化程序 (??_E?_mainWindow@Game@@0VRenderWindow@sf@@A@@YAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 11 错误 LNK2019:无法解析的外部符号 "__declspec(dllimport) 公共:虚拟 _thiscall sf::RenderWindow::~RenderWindow(void)" (_imp_??1RenderWindow@sf@@UAE@XZ) 在函数“void”中引用 __cdecl 'private: static class sf::RenderWindow Game::mainWindow''(void)' 的动态 atexit 析构函数 (??_F?_mainWindow@Game@@0VRenderWindow@sf@@A@@YAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

错误 12 错误 LNK1120: 11 未解决 外部 c:\Users\Harley\cppprojects\Pong\PongSFML\Debug\PongSFML.exe 1 1 PongSFML

我已经进行了大量研究以尝试解决此问题,但没有任何建议有效或根本没有改变任何东西。我检查了我的其他依赖项,没有出现任何拼写错误:

sfml-main-d.lib;sfml-audio-d.lib;sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib;

我的发布依赖:

sfml-system.lib;sfml-window.lib;sfml-graphics.lib;sfml-audio.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib ;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;

再说一次,我是 C++ 新手,所以我可能会做一些非常愚蠢的事情。我不认为我的源代码与它有任何关系,但是有人建议我添加

#pragma comment(lib, "sfml-main-d.lib")
#pragma comment(lib, "sfml-system-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-graphics-d.lib")

在我的主要方法之上,所以我做了。

有谁知道我做错了什么?

谢谢

【问题讨论】:

    标签: c++ visual-studio visual-studio-2012 linker sfml


    【解决方案1】:

    我无法添加评论,但您能否将链接器设置为 /VERBOSE,以便查看链接器找到了哪些库以及您指定的 .lib 是否实际链接到了?

    设置在 C++ > Linker > Progress I think

    编辑:http://s30.postimg.org/485cmfnk1/temp.png

    【讨论】:

    • 我不知道该怎么做。您是说属性中的 C++ 吗?我检查了属性中的 C++ 区域,没有关于链接器的内容。
    • 将“显示进度”字段设置为 /VERBOSE
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 2011-08-26
    • 1970-01-01
    相关资源
    最近更新 更多