Menu

undefined reference error can't resolve

HammyW
2007-11-14
2012-09-26
  • HammyW

    HammyW - 2007-11-14

    I am using Dev-C++ version 4.9.9.2 with windows XP and trying to make a game engine from code in a beginning game programming book. I have created a project with one header file and one source file and unable to compile. I've researched the other threads and still am confused. Any help appreciated, below is a copy of my compile log:

    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Wayne\game\Makefile.win"
    Executing make clean
    rm -f GameEngine.o "game engine.exe"

    g++.exe -DDEBUG -c GameEngine.cpp -o GameEngine.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne" -I"C:/Dev-Cpp/Wayne/game" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne/game" -g3

    g++.exe -DDEBUG GameEngine.o -o "game engine.exe" -L"C:/Dev-Cpp/lib" -mwindows -g3

    GameEngine.o(.text+0xd): In function ZN10GameEngine9SetWindowEP6HWND__': C:/Dev-Cpp/Wayne/game/GameEngine.h: undefined reference toGameInitialize(HINSTANCE*)'
    GameEngine.o(.text+0xcf):C:/Dev-Cpp/Wayne/game/GameEngine.h: undefined reference to GameCycle()' GameEngine.o(.text+0xe1):C:/Dev-Cpp/Wayne/game/GameEngine.h: undefined reference toGameEnd()'
    GameEngine.o(.text+0x5b7): In function ZN10GameEngine11HandleEventEP6HWND__jjl': C:/Dev-Cpp/Wayne/game/GameEngine.cpp:136: undefined reference toGameStart(HWND
    )'
    GameEngine.o(.text+0x5ce):C:/Dev-Cpp/Wayne/game/GameEngine.cpp:140: undefined reference to GameActivate(HWND__*)' GameEngine.o(.text+0x5f8):C:/Dev-Cpp/Wayne/game/GameEngine.cpp:145: undefined reference toGameDeactivate(HWND__
    )'
    GameEngine.o(.text+0x63a):C:/Dev-Cpp/Wayne/game/GameEngine.cpp:153: undefined reference to GamePaint(HDC__*)' GameEngine.o(.text+0x65d):C:/Dev-Cpp/Wayne/game/GameEngine.cpp:158: undefined reference toGameEnd()'
    collect2: ld returned 1 exit status

    make.exe: *** ["game] Error 1

    Execution terminated

     
    • Wayne Keen

      Wayne Keen - 2007-11-14

      Errors of this kind come from failing to link the correct library.

      In this case, I can't see where you tried to link any libraries.

      There is a section in the thread titled "Please Read Before Posting a Question" that
      covers the compile log, including headers, and linking libraries - it takes you through
      the why's and how's.

      Wayne

       
    • Anonymous

      Anonymous - 2007-11-14

      Read the next chapter of the book! http://www.gidforums.com/t-16228.html

      Next time it would be a good idea to tell us what book you are using. Others with the same book might be able to help you. I am just guessing from the symbol names (all I did to find this was to Google "GameDeactivate" - a bit of lateral thinking when searching always helps).

      Clifford

       
    • HammyW

      HammyW - 2007-11-14

      I have moved on in same book and now am stumped with this message from compile log, I get a cannot create Makefile.win I/O error 32

      Compiler: Default compiler
      Building Makefile: "C:\Dev-Cpp\Wayne\game\Makefile.win"
      Executing make clean
      make.exe: *** No rule to make target `clean'. Stop.

      Execution terminated

       
      • Osito

        Osito - 2007-11-14

        Try moving your project out of the dev-cpp folder. Although I don't think that's your problem.

         
    • HammyW

      HammyW - 2007-11-14

      For some reason unknown to me that worked and I was able to compile after some minor tweaks - thanks
      One more problem to solve and I think I'll be on my way. Here is my compiler log and a function that is supposed to draw icons in my window but nothing appears, does the icon file have to be a certain size?

      Compiler: Default compiler
      Building Makefile: "C:\game\Makefile.win"
      Executing make clean
      rm -f Blizzard.o GameEngine.o blizzard_private.res blizzard.exe

      g++.exe -DDEBUG -c Blizzard.cpp -o Blizzard.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne" -I"C:/Dev-Cpp/Wayne/game" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne/game" -g3

      g++.exe -DDEBUG -c GameEngine.cpp -o GameEngine.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne" -I"C:/Dev-Cpp/Wayne/game" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/Wayne/game" -g3

      windres.exe -i blizzard_private.rc --input-format=rc -o blizzard_private.res -O coff

      g++.exe -DDEBUG Blizzard.o GameEngine.o blizzard_private.res -o "blizzard.exe" -L"C:/Dev-Cpp/lib" -mwindows -g3

      Execution terminated
      Compilation successful

      My Function:

      void GameCycle()
      {
      HDC hDC;
      HWND hWindow = g_pGame->GetWindow();
      // Draw the snowflake icon at random positions on the game screen
      hDC = GetDC(hWindow);
      DrawIcon(hDC, rand() % g_pGame->GetWidth(), rand() % g_pGame->GetHeight(),
      (HICON)GetClassLong(hWindow, GCL_HICON));
      ReleaseDC(hWindow, hDC);
      }

       
      • Osito

        Osito - 2007-11-14

        I haven't used DrawIcon() - you might want to check here and make sure you're calling it correctly:

        http://msdn2.microsoft.com/en-us/library/ms648051.aspx

         
    • Anonymous

      Anonymous - 2007-11-14

      > For some reason unknown to me that worked ...

      It is a strange but known bug of Dev-C++ that when you create a project win the Dev-C++ installation folder it may fail to build. I t is unfortunate that that is where Dev installs its own examples! Other than that I cant think of a good reason to create projects in a program's installation folder.

      Clifford

       
    • HammyW

      HammyW - 2007-11-14

      Thanks for the reply, the book I'm using is Beginning Game Programming by Michael Morrison. Thanks for that link Clifford it was the same problem I had and now it makes sense. The book didn't really explain that, anyway I'll move forward and hopefully have better luck.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.