简体   繁体   English

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

[英]C++ Visual Studio 2012 Linker Errors?

I'm pretty new to C++ and I was setting up a project with SFML, which was working fine, I have no code issues according to Visual Studio, but when I debug I get these error messages: 我是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 错误1错误LNK2019:无法解析的外部符号“ __declspec(dllimport)公共:__thiscall sf :: String :: String(char const *,class std :: locale const&)”(_ imp ?? 0String @ sf @@ QAE @ PBDABVlocale函数“ public:static void __cdecl Game :: Start(void)”(?Start @ Game @@ SAXXZ)c:\\ Users \\ Harley \\ cppprojects \\ Pong \\ PongSFML \\ PongSFML \\ Game中引用了@std @@@@ Z)。 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 错误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

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 错误3错误LNK2019:无法解析的外部符号“ __declspec(dllimport)公共:_ thiscall sf :: VideoMode :: VideoMode(unsigned int,unsigned int,unsigned int)”( _imp _ ?? 0VideoMode @ sf @@ QAE @ III @ Z)在函数“公共:静态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 错误4错误LNK2019:无法解析的外部符号“ __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)在函数“ 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 错误5错误LNK2019:未解析的外部符号“ __declspec(dllimport)public:void _ thiscall sf :: Window :: close(void)”( _imp_?close @ Window @ sf @@ QAEXXZ)在函数“ 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 错误6错误LNK2019:未解析的外部符号“ __declspec(dllimport)公共:bool _此调用sf :: Window :: pollEvent(class sf :: Event&)”( _imp_?pollEvent @ Window @ sf @@ QAE_NAAVEvent @ 2 @@ Z )在函数“ 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 错误7错误LNK2019:无法解析的外部符号“ __declspec(dllimport)public:void _ thiscall sf :: Window :: display(void)”( _imp_?display @ Window @ sf @@ QAEXXZ)在函数“ 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 错误8错误LNK2019:无法解析的外部符号“ __declspec(dllimport)公共:_ thiscall sf :: Color :: Color(unsigned char,unsigned char,unsigned char,unsigned char)”( _imp _ ?? 0Color @ sf @@ QAE @ EEEE @Z)在函数“私有:静态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 错误9错误LNK2019:未解析的外部符号“ __declspec(dllimport)公共:void _此调用sf :: RenderTarget :: clear(class sf :: Color const&)”( _imp_?clear @ RenderTarget @ sf @@ QAEXABVColor @ 2 @@ Z)在函数“私人:静态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 错误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

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 错误11错误LNK2019:未解析的外部符号“ __declspec(dllimport)公共:虚拟_ thiscall sf :: RenderWindow :: 〜RenderWindow (void)”( _imp _ ?? 1RenderWindow @ sf @@ UAE @ XZ)在函数“ void __cdecl`”中引用动态私有属性的析构函数,用于“私有:静态类sf :: RenderWindow游戏:: 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 错误12错误LNK1120:11无法解析的外部文件c:\\ Users \\ Harley \\ cppprojects \\ Pong \\ PongSFML \\ Debug \\ PongSFML.exe 1 1 PongSFML

I've already done quite a bit of research to try to fix this, but no suggestions worked or changed anything at all. 为了解决这个问题,我已经进行了大量研究,但是没有任何建议有效或完全没有任何改变。 I checked through my additional dependencies and I didn't make any spelling errors: 我检查了我的其他依赖项,但没有出现任何拼写错误:

sfml-main-d.lib;sfml-audio-d.lib;sfml-system-d.lib;sfml-window-d.lib;sfml-graphics-d.lib; SFML-主d.lib; SFML-音频d.lib; SFML系统-d.lib; SFML窗口-d.lib; SFML-图形d.lib;

My release dependencies: 我的发布依赖项:

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

Once again, I'm new to C++ so I may be doing something incredibly stupid. 再一次,我是C ++的新手,所以我可能在做一些非常愚蠢的事情。 I don't think my source code has anything to do with it, however someone suggested that I add 我认为我的源代码与它无关,但是有人建议我添加

#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")

above my main method, so I did. 以上是我的主要方法,所以我做到了。

Does anyone know what I'm doing wrong? 有人知道我在做什么错吗?

Thanks 谢谢

I can't add a comment, but can you set the linker to /VERBOSE so you can see what libraries the linker has found and whether the .lib 's you specified are actually getting linked in? 我无法添加评论,但是可以将链接器设置为/VERBOSE以便可以看到链接器找到了哪些库,以及指定的.lib是否实际上已链接到其中?

The setting is under C++ > Linker > Progress I think 我认为该设置在C ++>链接器>进度下

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM