Note that there are some explanatory texts on larger screens.

plurals
  1. POerror LNK2001 and error LNK2019 (C++) -- Requesting some learning about these errors
    primarykey
    data
    text
    <p>Alright, so I just finished my last compiler error (so I thought) and these errors came up:</p> <pre><code>1&gt;GameEngine.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) 1&gt;Component.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) 1&gt;Coordinate.obj : error LNK2019: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) referenced in function "public: double __thiscall Coordinate::distanceFrom(class Coordinate *)" (?distanceFrom@Coordinate@@QAENPAV1@@Z) 1&gt;Driver.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) 1&gt;Environment.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA) 1&gt;Environment.obj : error LNK2001: unresolved external symbol "public: static bool Environment::spyFlag" (?spyFlag@Environment@@2_NA) 1&gt;Environment.obj : error LNK2001: unresolved external symbol "private: static class Environment * Environment::instance_" (?instance_@Environment@@0PAV1@A) 1&gt;Environment.obj : error LNK2019: unresolved external symbol "public: static void __cdecl Environment::spyAlertOver(void)" (?spyAlertOver@Environment@@SAXXZ) referenced in function "public: void __thiscall Environment::notificationOfSpySuccess(void)" (?notificationOfSpySuccess@Environment@@QAEXXZ) 1&gt;GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl MainMenu::gameOver(int)" (?gameOver@MainMenu@@SAXH@Z) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ) 1&gt;GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameDriver::gatherInput(void)" (?gatherInput@GameDriver@@SAXXZ) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ) 1&gt;GameDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameDriver::ticker(void)" (?ticker@GameDriver@@SAXXZ) referenced in function "public: static void __cdecl GameDriver::run(void)" (?run@GameDriver@@SAXXZ) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static int GameDriver::ticks" (?ticks@GameDriver@@2HA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::evaluatingInputFlag" (?evaluatingInputFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyQuitFlag" (?keyQuitFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponRightFlag" (?keyToggleWeaponRightFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponLeftFlag" (?keyToggleWeaponLeftFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyFireFlag" (?keyFireFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyLeftFlag" (?keyLeftFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyRightFlag" (?keyRightFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyUpFlag" (?keyUpFlag@GameDriver@@2_NA) 1&gt;GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyDownFlag" (?keyDownFlag@GameDriver@@2_NA) 1&gt;GUI_Env.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Env::buffer" (?buffer@GUI_Env@@0PAUBITMAP@@A) 1&gt;GUI_Info.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Info::buffer" (?buffer@GUI_Info@@0PAUBITMAP@@A) 1&gt;MenuDriver.obj : error LNK2019: unresolved external symbol "public: static void __cdecl MainMenu::displayMenu(void)" (?displayMenu@MainMenu@@SAXXZ) referenced in function "public: static void __cdecl MenuDriver::start(void)" (?start@MenuDriver@@SAXXZ) 1&gt;SpaceObjectFactory.obj : error LNK2001: unresolved external symbol "private: static class SpaceObjectFactory * SpaceObjectFactory::_instance" (?_instance@SpaceObjectFactory@@0PAV1@A) 1&gt;Spy.obj : error LNK2019: unresolved external symbol "public: virtual bool __thiscall UnFormationable::sameTypeOfSpaceObjectAs(class SpaceObject *)" (?sameTypeOfSpaceObjectAs@UnFormationable@@UAE_NPAVSpaceObject@@@Z) referenced in function "public: virtual bool __thiscall Spy::sameTypeOfSpaceObjectAs(class SpaceObject *)" (?sameTypeOfSpaceObjectAs@Spy@@UAE_NPAVSpaceObject@@@Z) 1&gt;WeaponsDB.obj : error LNK2001: unresolved external symbol "private: static class WeaponsDB * WeaponsDB::_instance" (?_instance@WeaponsDB@@0PAV1@A) 1&gt;C:\Users\Owner\Desktop\Bosconian\code\Bosconian\Debug\Bosconian.exe : fatal error LNK1120: 23 unresolved externals </code></pre> <p>Alright, here's a brief overview.</p> <p>PI is a static constant in WeaponsDB and is referenced by other classes using WeaponsDB::PI and the appropriate #include (what's wrong with this?)</p> <p>Most other errors stem from static variables and static methods for timers from the allegro gaming library.</p> <p>What causes these errors and how might I get rid of them?</p> <p>Thanks in advance</p> <p>----------------Edits-------------------</p> <p>As requested, where the WeaponsDB::PI is declared and defined. It is declared in WeaponsDB.h:</p> <pre><code>public: static double PI; </code></pre> <p>But it is defined in another class Driver.cpp:</p> <pre><code>WeaponsDB::PI = 4*atan(1.0); </code></pre> <p>If this is one of the problems with my code I would love to know why this causes an error.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload