1

When I try to build my C++ application, I get a lot of unresolved external errors:

1>game.obj : error LNK2019: unresolved external symbol "public: __thiscall Player::Player(void)" (??0Player@@QAE@XZ) referenced in function "public: __thiscall Game::Game(void)" (??0Game@@QAE@XZ)
1>game.obj : error LNK2019: unresolved external symbol "public: __thiscall Player::Player(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Player@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Game::newMonster(void)" (?newMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Player::gameOver(void)" (?gameOver@Player@@QAE_NXZ) referenced in function "public: void __thiscall Game::defaultMenu(void)" (?defaultMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::updatePet(int,class Pet *)" (?updatePet@Player@@QAEXHPAVPet@@@Z) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Player::enemyName(void)" (?enemyName@Player@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class Pet * __thiscall Player::getMonster(int)" (?getMonster@Player@@QAEPAVPet@@H@Z) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: int __thiscall Player::getMonsterSize(void)" (?getMonsterSize@Player@@QAEHXZ) referenced in function "public: void __thiscall Game::inGameMenu(void)" (?inGameMenu@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Player::getName(void)" (?getName@Player@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: void __thiscall Game::saveMonster(void)" (?saveMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::addMonster(class Pet *)" (?addMonster@Player@@QAEXPAVPet@@@Z) referenced in function "public: void __thiscall Game::loadMonster(void)" (?loadMonster@Game@@QAEXXZ)
1>game.obj : error LNK2019: unresolved external symbol "public: void __thiscall Player::setName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setName@Player@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Game::loadMonster(void)" (?loadMonster@Game@@QAEXXZ)
1>fatal error LNK1120: 10 unresolved externals

The thing is, these errors didn't show up a couple days ago. They just appeared suddenly out of nowhere.

I also have included my Player.h inside the Player.cpp and Game.cpp where it should be needed.

Can anyone help me here?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
andranos
  • 11
  • 1
  • 2
  • Looks like you're not linking your `Player.obj` file / not compiling your `Player.cpp` file. You should try and take another look to your build command, or check your file and see if you're not missing those methods definitions. – Nbr44 May 23 '13 at 07:30
  • It would seem that player.cpp isn't included in your build tho'. – Mats Petersson May 23 '13 at 07:30
  • Is there any way I check whether it is included or not? – andranos May 23 '13 at 07:42
  • Have you tried a `Rebuild All`? – Peter Wood May 23 '13 at 07:48
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Peter Wood May 23 '13 at 07:49

0 Answers0