gpt4 book ai didi

C++ Visual Studio 2012 链接器错误?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:25:11 24 4
gpt4 key购买 nike

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

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (_imp??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function "public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: _thiscall sf::String::~String(void)" (_imp_??1String@sf@@QAE@XZ) referenced in function "public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 3 error LNK2019: unresolved external symbol "__declspec(dllimport) public: _thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (_imp_??0VideoMode@sf@@QAE@III@Z) referenced in function "public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 4 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void _thiscall sf::Window::create(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (_imp_?create@Window@sf@@QAEXVVideoMode@2@ABVString@2@IABUContextSettings@2@@Z) referenced in function "public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 5 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void _thiscall sf::Window::close(void)" (_imp_?close@Window@sf@@QAEXXZ) referenced in function "public: static void __cdecl Game::Start(void)" (?Start@Game@@SAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 6 error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool _thiscall sf::Window::pollEvent(class sf::Event &)" (_imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function "private: static void __cdecl Game::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void _thiscall sf::Window::display(void)" (_imp_?display@Window@sf@@QAEXXZ) referenced in function "private: static void __cdecl Game::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 8 error LNK2019: unresolved external symbol "__declspec(dllimport) public: _thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (_imp_??0Color@sf@@QAE@EEEE@Z) referenced in function "private: static void __cdecl Game::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 9 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void _thiscall sf::RenderTarget::clear(class sf::Color const &)" (_imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function "private: static void __cdecl Game::GameLoop(void)" (?GameLoop@Game@@CAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 10 error LNK2019: unresolved external symbol "__declspec(dllimport) public: _thiscall sf::RenderWindow::RenderWindow(void)" (_imp_??0RenderWindow@sf@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for '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

Error 11 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual _thiscall sf::RenderWindow::~RenderWindow(void)" (_imp_??1RenderWindow@sf@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'private: static class sf::RenderWindow Game::mainWindow''(void)" (??_F?_mainWindow@Game@@0VRenderWindow@sf@@A@@YAXXZ) c:\Users\Harley\cppprojects\Pong\PongSFML\PongSFML\Game.obj PongSFML

Error 12 error LNK1120: 11 unresolved externals 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")

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

有人知道我做错了什么吗?

谢谢

最佳答案

我不能添加评论,但是你可以将链接器设置为 /VERBOSE 这样你就可以看到链接器找到了哪些库以及 .lib'你指定的是否真的被链接进来了?

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

编辑:http://s30.postimg.org/485cmfnk1/temp.png <-- 这里

关于C++ Visual Studio 2012 链接器错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20482845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com