【发布时间】: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