よし、最後のコンパイラ エラーを終了したところ (そう思った)、次のエラーが表示されました。
1>GameEngine.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Component.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>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>Driver.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Environment.obj : error LNK2001: unresolved external symbol "public: static double WeaponsDB::PI" (?PI@WeaponsDB@@2NA)
1>Environment.obj : error LNK2001: unresolved external symbol "public: static bool Environment::spyFlag" (?spyFlag@Environment@@2_NA)
1>Environment.obj : error LNK2001: unresolved external symbol "private: static class Environment * Environment::instance_" (?instance_@Environment@@0PAV1@A)
1>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>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>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>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>GameDriver.obj : error LNK2001: unresolved external symbol "public: static int GameDriver::ticks" (?ticks@GameDriver@@2HA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::evaluatingInputFlag" (?evaluatingInputFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyQuitFlag" (?keyQuitFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponRightFlag" (?keyToggleWeaponRightFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyToggleWeaponLeftFlag" (?keyToggleWeaponLeftFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyFireFlag" (?keyFireFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyLeftFlag" (?keyLeftFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyRightFlag" (?keyRightFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyUpFlag" (?keyUpFlag@GameDriver@@2_NA)
1>GameDriver.obj : error LNK2001: unresolved external symbol "public: static bool GameDriver::keyDownFlag" (?keyDownFlag@GameDriver@@2_NA)
1>GUI_Env.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Env::buffer" (?buffer@GUI_Env@@0PAUBITMAP@@A)
1>GUI_Info.obj : error LNK2001: unresolved external symbol "private: static struct BITMAP * GUI_Info::buffer" (?buffer@GUI_Info@@0PAUBITMAP@@A)
1>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>SpaceObjectFactory.obj : error LNK2001: unresolved external symbol "private: static class SpaceObjectFactory * SpaceObjectFactory::_instance" (?_instance@SpaceObjectFactory@@0PAV1@A)
1>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>WeaponsDB.obj : error LNK2001: unresolved external symbol "private: static class WeaponsDB * WeaponsDB::_instance" (?_instance@WeaponsDB@@0PAV1@A)
1>C:\Users\Owner\Desktop\Bosconian\code\Bosconian\Debug\Bosconian.exe : fatal error LNK1120: 23 unresolved externals
さて、ここで簡単な概要です。
PI は WeaponsDB の静的定数であり、WeaponsDB::PI と適切な #include を使用して他のクラスによって参照されます (これの何が問題なのですか?)
他のほとんどのエラーは、allegro ゲーム ライブラリのタイマーの静的変数と静的メソッドに起因します。
これらのエラーの原因と、それらを取り除く方法は?
前もって感謝します
----------------編集内容-------------------
要求に応じて、WeaponsDB::PI が宣言および定義されます。WeaponsDB.h で宣言されています。
public:
static double PI;
ただし、別のクラス Driver.cpp で定義されています。
WeaponsDB::PI = 4*atan(1.0);
これが私のコードの問題の 1 つである場合、これがエラーを引き起こす理由を知りたいです。