Menu

New Programmer, New Program Question:

Lame Brain
2010-07-07
2012-09-26
  • Lame Brain

    Lame Brain - 2010-07-07

    Hello.
    I am reading "Advanced 2D Game Development" by Jonathan S. Harbour and I am
    attempting to follow along. I have created the three .h files and the three
    .cpp files as he lays out (I am using the bloodshed IDE Version 4.9.9.2) and
    have created the test program as it is written in the book:

    [code]#include <iostream>
    #include "..\Engine\DeathChicken.h"
    
    bool game_preload()
    {
         //engine version display
         g_engine->message(g_engine->getVersionText(), "Test Engine");
         //return fail to terminate engine
         return 0;
    }
    
    bool game_init(HWND hwnd) { return 0; }
    bool game_update() { return 0; }
    bool game_end() { return 0; }[/code]
    

    Everything is mostly working, but I am getting a series of Linker errors that
    I do not understand. I have been doing some searches, but nothing that looks
    like it will help. Here are the linker errors:

    [code]
      [Linker error] undefined reference to `DeathChicken::Engine::getVersionText()' 
      [Linker error] undefined reference to `DeathChicken::Engine::message(std::string, std::string)' 
      [Linker error] undefined reference to `DeathChicken::Engine::Engine()' 
      [Linker error] undefined reference to `DeathChicken::Engine::Init(int, int, int, bool)' 
      [Linker error] undefined reference to `DeathChicken::Engine::Update()' 
      [Linker error] undefined reference to `DeathChicken::Engine::Close()' 
    [/code]
    

    What I am finding is weird, is that these are some of the methods from
    DeathChicken.h and DeathChicken.cpp, but not all of them. What should I be
    looking for to get this to work?

     
  • Lame Brain

    Lame Brain - 2010-07-07

    I zipped my files in case someone needs to look at them to help. I do not see
    a way to attach them to the forum, but if you mail me at DIntentGmailcom I
    will send the zip file to you. (it is only 829KB)

     
  • cpns

    cpns - 2010-07-08

    Post the complete build log text from the "Compile Log" tab not the
    "Compiler" tab. It is plain text so is a simple copy and paste, and it
    contains all the necessary diagnostic information including how your project
    is setup.

    Note that you do need to create a project for a multi-module build, and add
    all your source files to the project, otherwise the linker will not know
    what to include in the build. I strongly suspect that that is your problem.
    The "Compile Log" will have told us if that were the case, which is why in the
    PLEASE READ BEFORE POSTING A QUESTION thread, you are requested to post
    it!

    What I am finding is weird, is that these are some of the methods from
    DeathChicken.h and DeathChicken.cpp, but not all of them.

    The linker will only attempt to resolve references to symbols actually
    referenced in the compiled code. If there were no references to the other
    symbols, there is nothing to resolve!

     
  • Lame Brain

    Lame Brain - 2010-07-09

    Sorry.
    Here is the compile log:

    Compiler: Default compiler
    Building Makefile: "D:\Dev-Cpp\ChknTest\Devcpp\Makefile.win"
    Executing make...
    make.exe -f "D:\Dev-Cpp\ChknTest\Devcpp\Makefile.win" all
    g++.exe ./obj/main.o -o "..\bin\ChknTest.exe" -L"D:/Dev-Cpp/lib"
    -L"../../Engine/lib/" -mwindows -lDeathChicken -ld3d9 -ld3dx9 -ldxguid -lwinmm
    -luser32 -lgdi32

    ./obj/main.o(.text+0x184):main.cpp: undefined reference to
    DeathChicken::Engine::getVersionText()' ./obj/main.o(.text+0x1ac):main.cpp: undefined reference toDeathChicken::Engine::message(std::string, std::string)'
    ../../Engine/lib//libDeathChicken.a(WinMain.o)(.text+0x1e8):WinMain.cpp:
    undefined reference to DeathChicken::Engine::Engine()' ../../Engine/lib//libDeathChicken.a(WinMain.o)(.text+0x6d9):WinMain.cpp: undefined reference toDeathChicken::Engine::Init(int, int, int, bool)'
    ../../Engine/lib//libDeathChicken.a(WinMain.o)(.text+0x795):WinMain.cpp:
    undefined reference to DeathChicken::Engine::Update()' ../../Engine/lib//libDeathChicken.a(WinMain.o)(.text+0x7d8):WinMain.cpp: undefined reference toDeathChicken::Engine::Close()'
    collect2: ld returned 1 exit status

    make.exe: *** Error 1

    Execution terminated

     
  • cpns

    cpns - 2010-07-09

    It would appear that ../../Engine/lib/libDeathChicken.a does not contain the
    DeathChicken::Engine:: member functions you have made reference to or indeed
    the members it makes reference to itself. Are these implementatuions that you
    have provided in separate modules? The only Object file you are linking is
    main.o; you said tehre were three .cpp files, but you have only compiled and
    linked one. So as I said, you need to use a 'project' (File->New->Project),
    and add all the .cpp sources to it as well as setting up the library paths and
    libraries to be linked.

     
  • cpns

    cpns - 2010-07-09

    "implementatuions" !!! -> implementations

     
  • Lame Brain

    Lame Brain - 2010-07-12

    The six other files are supposed to collapse down into DeathChicken.a, as for
    DeathChicken.h, it is supposed to reference the other files. Maybe I
    configured the project wrong?

     
  • cpns

    cpns - 2010-07-12

    For that to work you must have had a separate project to build
    libDeathChicken.a; perhaps you need to post the log from that (from a Rebuild
    All), to see what it is composed of. That said, why bother with creating a
    static library for this? You could just include all the sources in this
    project.

     
  • Lame Brain

    Lame Brain - 2010-07-12

    When I get home I will post that.
    The intent is that that the DeathChicken.a will eventually be an Engine, and
    comes from a book called "Advanced 2D Game Development" by Jonathan S.
    Harbour.

    The program I am attempting to write here is just to initialize the engine and
    make sure it works. (LOL! I'm not doing too good!)

     
  • Lame Brain

    Lame Brain - 2010-07-13

    Here is that log when I compile WinMain.cpp from engine project:

    Compiler: Default compiler
    Building Makefile: "D:\Dev-Cpp\Engine\Devcpp\Makefile.win"
    Executing make...
    make.exe -f "D:\Dev-Cpp\Engine\Devcpp\Makefile.win" all
    ar r ../lib/libDeathChicken.a ./obj/WinMain.o

    ar: creating ../lib/libDeathChicken.a

    ranlib ../lib/libDeathChicken.a

    Execution terminated

     
  • Lame Brain

    Lame Brain - 2010-07-13

    I figured I might as well post the rest of it. DeathChicken.h:

    //The Death Chicken Engine
    //Main Header File
    //Ethan Roberts 2010
    
    #ifndef _DEATHCHICKEN_H
    #define _DEATHCHICKEN_H 1
    
    #include <iostream>
    #include <windows.h>
    #include <d3d9.h>
    #include <d3dx9.h>
    #include <dxerr9.h>
    #include "Timer.h"
    
    #define VERSION_MAJOR 1
    #define VERSION_MINOR 0
    #define REVISION 0
    
    //external variables and fuctions
    extern bool gameover;
    extern bool game_preload();
    extern bool game_init(HWND);
    extern bool game_update();
    extern bool game_end();
    
    namespace DeathChicken
    {
              class Engine {
                  private:
                          int p_versionMajor, p_versionMinor, p_revision;
                          HWND p_windowHandle;
                          LPDIRECT3D9 p_d3d;
                          LPDIRECT3DDEVICE9 p_device;
                          LPDIRECT3DSURFACE9 p_backbuffer;
                          LPD3DXSPRITE p_sprite_handler;
                          std::string p_appTitle;
                          bool p_fullscreen;
                          int p_screenwidth;
                          int p_screenheight;
                          int p_colordepth;
                          bool p_pauseMode;
                          D3DCOLOR p_ambientColor;
                          bool p_maximizeProcessor;
                          Timer p_coreTimer;
                          long p_frameCount_core;
                          long p_frameRate_core;
                          Timer p_realTimer;
                          long p_frameCount_real;
                          long p_frameRate_real;
                  public:
                         Engine();
                         virtual ~Engine();
                         int Init(int width, int height, int colordepth, bool fullscreen);
                         void Close();
                         void Update();
                         void message(std::string message, std::string title = "Death Chicken Engine");
                         void fatalerror(std::string message, std::string title = "Fatal Error");
                         void Shutdown();
                         void ClearScene(D3DCOLOR color);
                         void SetDefaultMaterial();
                         void SetAmbient(D3DCOLOR colorvalue);
                         int RenderStart();
                         int RenderStop();
                         int Release();
    
                         //accessor/mutator functions expose the private variables
                         bool isPaused() {return this->p_pauseMode; }
                         void setPaused(bool value) { this->p_pauseMode = value; }
                         LPDIRECT3DDEVICE9 getDevice() { return this->p_device; }
                         LPDIRECT3DSURFACE9 getBackBuffer() { return this->p_backbuffer; }
                         LPD3DXSPRITE getSpriteHandler() { return this->p_sprite_handler; }
                         void setWindowHandle(HWND hwnd) { this->p_windowHandle = hwnd; }
                         HWND getWindowHandle() { return this->p_windowHandle; }
                         std::string getAppTitle() { return this->p_appTitle; }
                         void setAppTitle(std::string value) { this->p_appTitle = value; }
                         int getVersionMajor() { return this->p_versionMajor; }
                         int getVersionMinor() { return this->p_versionMinor; }
                         int getRevision() { return this->p_revision; }
                         std::string getVersionText();
                         long getFrameRate_core() { return this->p_frameRate_core; }
                         long getFrameRate_real() { return this->p_frameRate_real; }
                         int getScreenWidth() { return this->p_screenwidth; }
                         void setScreenWidth(int value) { this->p_screenwidth = value; }
                         int getScreenHeight() { return this->p_screenheight; }
                         void setScreenHeight(int value) { this->p_screenheight = value; }
                         int getColorDepth() {return this->p_colordepth; }
                         void setColorDepth(int value) { this->p_colordepth = value; }
                         bool getFullscreen() { return this->p_fullscreen; }
                         void setFullscreen(bool value) {this->p_fullscreen = value; }
                         bool getMaximumProcessor() { return this->p_maximizeProcessor; }
                         void setMaximumProcessor(bool value) {this->p_maximizeProcessor = value; }
    
                         }; //class end
                  };//namespace end
                  //define the global engine object
                  extern DeathChicken::Engine *g_engine;
    
                  #endif
    
     
  • Lame Brain

    Lame Brain - 2010-07-13

    Timer.h:

    //Timing Header
    //Ethan Roberts, 2010
    // Timer class provides timing and stopwatch features
    #pragma once
    #include <time.h>
    #include <windows.h>
    namespace DeathChicken 
    {
              class Timer
              {
                    private:
                            DWORD timer_start;
                            DWORD stopwatch_start;
                    public:
                           Timer(void);
                           ~Timer(void);
                           DWORD getTimer();
                           DWORD getStartTimeMillis();
                           void sleep(int ms);
                           void reset ();
                           bool stopwatch(int ms);
              };
    };
    
     
  • Lame Brain

    Lame Brain - 2010-07-13

    WinMain.h:

    #ifndef _WINMAIN_H
    #define _WINMAIN_H 1
    
    #define WIN32_LEAN_AND_MEAN
    #define WIN32_EXTRA_LEAN
    #include <iostream>
    #include <windows.h>
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "DeathChicken.h"
    #endif
    
     
  • Lame Brain

    Lame Brain - 2010-07-13

    DeathChicken.cpp:

    //The Death Chicken Engine
    //Ethan Roberts, 2010
    //Main source file
    
    //includes
    #include "DeathChicken.h"
    #include <cstdlib>
    #include <ctime>
    #include <string>
    #include <sstream>
    #include <list>
    #include "winmain.h"
    
    namespace DeathChicken
    {
              Engine::Engine()
              {
                              srand((unsigned int)time(NULL));
                              p_maximizeProcessor = false;
                              p_frameCount_core = 0;
                              p_frameRate_core = 0;
                              p_frameCount_real = 0;
                              p_frameRate_real = 0;
                              p_ambientColor = D3DCOLOR_RGBA(255,255,255,0);
                              p_windowHandle = 0;
                              p_pauseMode = false;
                              p_versionMajor = VERSION_MAJOR;
                              p_versionMinor = VERSION_MINOR;
                              p_revision = REVISION;
    
                              //set default values
                              this->setAppTitle("DeathChicken");
                              this->setScreenWidth(640);
                              this->setScreenHeight(480);
                              this->setColorDepth(32);
                              this->setFullscreen(false);
    
                              //window handle must be set later on for directX!
                              this->setWindowHandle(0);
                              }
    
              Engine::~Engine()
              {
                               if (this->p_device) this->p_device->Release();
                               if (this->p_d3d) this->p_d3d->Release();
                               }
    
              std::string Engine::getVersionText()
              {
                          std::ostringstream s;
                          s << "DeathChicken Engine v" << p_versionMajor << "." << p_versionMinor << "." << p_revision;
                          return s.str();
                          }
    
              void Engine::message(std::string message, std::string title)
              {
                   MessageBox(0, message.c_str(), title.c_str(), 0);
                   }
    
              void Engine::fatalerror(std::string message, std::string title)
              {
                   this->message(message,title);
                   Shutdown(); 
                   }
    
              int Engine::Init(int width, int height, int colordepth, bool fullscreen)        
              {
                  //initialize Direct3D
                  this->p_d3d = Direct3DCreate9(D3D_SDK_VERSION);
                  if(this->p_d3d == NULL) { return 0; }
    
                  //get system desktop color depth
                  D3DDISPLAYMODE dm;
                  this->p_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
    
                  //set configuration options
                  D3DPRESENT_PARAMETERS d3dpp;
                  ZeroMemory(&d3dpp, sizeof(d3dpp));
                  d3dpp.Windowed = (!fullscreen);
                  d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
                  d3dpp.EnableAutoDepthStencil = TRUE;
                  d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
                  d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
                  d3dpp.BackBufferFormat = dm.Format;
                  d3dpp.BackBufferCount = 1;
                  d3dpp.BackBufferWidth = width;
                  d3dpp.BackBufferHeight = height;
                  d3dpp.hDeviceWindow = p_windowHandle;
    
                  //create direct3d device
                  this->p_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, this->p_windowHandle, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &this->p_device);
                  if (this->p_device == NULL) return 0;
    
                  //clear the backbuffer to black
                  this->ClearScene(D3DCOLOR_XRGB(0,0,0));
    
                  //create pointer to the back buffer
                  this->p_device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &this->p_backbuffer);
    
                  //use ambient lighting and z-buffering
                  this->p_device->SetRenderState(D3DRS_ZENABLE, TRUE);
                  this->p_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
                  this->SetAmbient(this->p_ambientColor);
    
                  //initialize the 2D renderer
                  HRESULT result = D3DXCreateSprite(this->p_device, &this->p_sprite_handler);
                  if (result!=D3D_OK) return 0;
    
                  //call game initialization extern function
                  if (!game_init(this->getWindowHandle())) return 0;
    
                  //set a default material
                  SetDefaultMaterial();
                  return 1;
                  }
    
              void Engine::SetDefualtMaterial()
              {
                   D3DMATERIAL9 mat;
                   memset(&mat, 0, sizeof(mat));
                   mat.Diffuse.r = 1.0f;
                   mat.Diffuse.g = 1.0f;
                   mat.Diffuse.b = 1.0f;
                   mat.Diffuse.a = 1.0f;
                   p_device->SetMaterial(&mat);
                   }
    
              void Engine::ClearScene(D3DCOLOR color)
              {
                   this->p_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, color, 1.0f, 0);
                   }
    
              void Engine::SetAmbient(D3DCOLOR colorvalue)
              {
                   this->p_ambientColor = colorvalue;
                   this->p_device->SetRenderState(D3DRS_AMBIENT, this->p_ambientColor);
                   }
    
              int Engine::RenderStart()
              {
                  if(!this->p_device) return 0;
                  if(this->p_device->BeginScene() != D3D_OK) return0l
                  return 1;
                  }
    
              int Engine::RenderStop()
              {
                  if(!this->p_device) return 0;
                  if(this->p_device->EndScene() != D3D_OK) return 0;
                  if(p_device->Present(NULL, NULL, NULL, NULL)!=D3D_OK) return 0;
                  return 1
                  }
    
              void Engine::Shutdown()
              {
                   gameover = true;
                   }
    
              void Engine::Update()
              {
                   static Timer timedUpdate;
    
                   //calculate core framerate
                   p_frameCount_core++;
                   if(p_coreTimer.stopwatch(999)) {
                       p_frameRate_core = p_frameCount_core;
                       p_frameCount_core = 0;
                       }
    
                   //fast update with no timing
                   game_update();
    
                   //update with 60fps timing
                   if(timedUpdate.stopwatch(14)) {
                       if(!this->getMaximizeProcessor()) {
                           Sleep(1);
                           }
                       }
                   else {
                        //calculate real framerate
                        p_frameCount_real++;
                        if(p_realTimer, stopwatch(999)) {
                            p_frameRate_real = p_frameCount_real;
                            p_frameCount_real = 0;
                            }
    
                        //begin rendering
                        this->RenderStart();
    
                        //done Rendering
                        this->RenderStop)();
    
                        }
                   }
    
                   void Engine::Close()
                   {
                        game_end();
                        }
              }//Namespace end
    
     
  • Lame Brain

    Lame Brain - 2010-07-13

    Timer.cpp:

    //Timer source file
    //Ethan Roberts, 2010
    
    #include "Timer.h"
    namespace DeathChicken
    {
              Timer::Timer(void)
              {
                            timer_start = timeGetTime();
                            reset();
              }
    
              Timer::~Timer(void)
              {
              }
    
              DWORD Timer::getTimer()
              {
                    return (DWORD) (timeGetTime());
              }
    
              DWORD Timer::getStartTimeMillis()
              {
                    return (DWORD) (getStartTime() - timer_start);
              }
    
              void Timer::sleep(int ms)
              {
                   DWORD start = getTimer();
                   while(start + ms > getTimer());
              }
    
              void Timer::reset()
              {
                   stopwatch_start = getTimer();
              }
    
              bool Timer::stopwatch(int ms)
              {
                   if(timeGetTime() > stopwatch_start + ms) {
                                    stopwatch_start = getTimer;
                                    return true;
                   }
                                   else return false;
                   }
                   };//Namespace end
    
     
  • Lame Brain

    Lame Brain - 2010-07-13

    WinMain.cpp:

    #include <sstream>
    #include "WinMain.h"
    #include "DeathChicken.h"
    
    //Macro to read key-states
    #define KEY_DOWN(vk) ((GetAsyncKeyState(vk) & 00x8000)?1:0)
    
    HINSTANCE g_hInstance;
    HWND g_hWnd;
    int g_nCmdShow;
    
    //declare global game engine object
    DeathChicken::Engine *g_engine;
    
    bool gameover;
    
    //window event callback function
    LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
    {
     switch( msg )
             {
             case WM_QUIT:
             case WM_CLOSE:
             case WM_DESTROY:
                  gameover = true;
                  break;
             }
     return DefWindowProc( hWnd, msg, wParam, lParam );
    }
    
    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
    {
        MSG msg;
        srand((unsigned int)time(NULL));
        g_hInstance = hInstance;
        g_nCmdShow = nCmdShow;
        DWORD dwStyle, dwExStyle;
        RECT windowRect;
    
        /** 
            *Create engine object
        **/
    
        g_engine = new DeathChicken::Engine();
    
        //Let main program have a crack at things before window is created
        if (!game_preload()) {
           MessageBox(g_hWnd, "Error in game preload!", "Error", MB_OK);
           return 0;
           }
    
        //get window caption string from engine
        char title[255];
        sprintf(title, "% s", g_engine->getAppTitle().c_str());
    
        //set window dimensions
        windowRect.left = (long)0;
        windowRect.right = (long)g_engine->getScreenWidth();
        windowRect.top = (long)0;
        windowRect.bottom = (long)g_engine->getScreenHeight();
    
        //create the window class structure
        WNDCLASSEX wc;
        wc.cbSize = sizeof(WNDCLASSEX);
    
        //fill the structure with info
        wc.style = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc = (WNDPROC)WinProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
        wc.hIcon = NULL;
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName = NULL;
        wc.hIconSm = NULL;
    
        //setup window with class info
        RegisterClassEx(&wc);
    
        //setup the screen in window mode or full screen?
    
        if (g_engine->getFullscreen())
        {
           DEVMODE dm;
           memset(&dm, 0, sizeof(dm));
           dm.dmSize = sizeof(dm);
           dm.dmPelsWidth = g_engine->getScreenWidth();
           dm.dmPelsHeight = g_engine->getScreenHeight();
           dm.dmBitsPerPel = g_engine->getColorDepth();
           dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
    
            if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
               MessageBox(NULL, "Display mode failed", NULL, MB_OK);
               g_engine->setFullscreen(false);
               }
    
            dwStyle = WS_POPUP;
            dwExStyle = WS_EX_APPWINDOW;
            ShowCursor(FALSE);
        }
        else {
             dwStyle = WS_OVERLAPPEDWINDOW;
             dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
        }
    
        //adust window to true requested size
        AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
    
        //create the program window
        g_hWnd = CreateWindowEx( 0,
               title, //window class
               title, //title bar
               dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
               0, 0, //w, y coords
               windowRect.right - windowRect.left, //width of the window
               windowRect.bottom - windowRect.top, //height of the window
               0, //parent window
               0, //menu
               g_hInstance, //game's app instance
               0); //window parameters
    
        //window creation error?
        if(!g_hWnd) { MessageBox(g_hWnd, "Error creating program window!", "Error", MB_OK); return 0; }
    
        //display the window
        ShowWindow(g_hWnd, g_nCmdShow);
        UpdateWindow(g_hWnd);
    
        //initialize game-engine
        g_engine->setWindowHandle(g_hWnd);
        if(!g_engine->Init(g_engine->getScreenWidth(), g_engine->getScreenHeight(), g_engine->getColorDepth(), g_engine->getFullscreen()))  { MessageBox(g_hWnd, "Engine Initialization is buggered", "Error", MB_OK); return 0;  }
    
        //main message loop
        gameover = false;
        while (!gameover)
        {
              while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
              {
                    TranslateMessage(&msg);
                    DispatchMessage(&msg);
              }
              g_engine->Update();
        }
    
        if (g_engine->getFullscreen()) { ShowCursor(TRUE);  }
    
        g_engine->Close();
        delete g_engine;
    
        return 1;
    }
    
     
  • cpns

    cpns - 2010-07-13

    Here is that log when I compile WinMain.cpp from engine project:

    That does not look like a log from a "Rebuild All" as I requested.

    However what I can tell from your logs is that the ChknTest project compiles
    main.cpp and links it to libDeathChicken.a. The libDeathChicken project
    compiles WinMain.cpp and places it in the libDeathChicken.a archive (library).
    What is clearly evident is that _nowhere _are either Timer.cpp or
    DeathChicken.cpp compiled and linked or archived. Which brings us back to the
    answer I gave in post #5 of this thread; these files must be added to the
    project to be compiled; presumably they are part of the engine so need to be
    added to the libDeathChicken project?

    I figured I might as well post the rest of it

    Since these are linker errors, the code is largely irrelevant. A list of files
    would have been useful however, so what you posted serves that purpose at
    least. The full logs from a rebuild all would also have provided more
    information, but I believe I have managed to infer all that was necessary from
    what you have posted.

    You need to add timer.cpp and DeathChicken.cpp to your library project,
    rebuild it and then link the _new _library to your test project. Good luck.

     
  • Lame Brain

    Lame Brain - 2010-07-15

    So how do I add these to the project?

     
  • cpns

    cpns - 2010-07-16

    I think you will find that ability to operate a computer is a prerequisite to
    being able to program one. The natural curiosity that would make you an
    effective programmer should also have caused you to at least browse the
    Dev-C++ menu strip and context (right-click) menus, in which case the answer
    to your question should be obvious.

    Either:

    1) Project->Add file
    2) Right click on the project name in the project pane, and select "Add files"

    As I said in post #3; you do have to create a project to compile and link
    multiple sources. If you have not done so, then the above menus will not be
    available. Perhaps less obvious is that fact that once you have created a
    project, you should set it up via the Project->Project Options... dialog,
    not the Tools->Compiler... dialog; the latter are the starting options for
    new projects (unless overridden by a template), and should be generic and not
    project specific; so for example do not add third-part libraries there unless
    they will be used in all your projects, and even then a template may be a
    better solution.

    The actual menu names may differ; I do not recall exactly since I no longer
    bother to install Dev-C++ - it is no longer maintained, and its debugger
    sucks, and there are better alternatives, there are few compelling reasons to
    continue using it.

     

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.