Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

15.01.2013, 17:43

Undefined reference to 'vtable for CEntity' (Linkerproblem?)

Guten Abend zusammen,
mein Compiler spuckt mir derzeit immer diese Fehlermeldung aus: Undefined reference to 'vtable for CEntity'. Das seltsame ist dass ich nicht wüsste etwas geändert zu haben seit es das letzte Mal funktioniert hat.

Der Fehler tritt in der Datei CEntity.cpp in der Zeile "CEntity::CEntity()" (Zeile 3) auf.


Folgendes habe ich dazu gefunden:Link, allerdings hat mir das nicht weiter geholfen da ich nicht wüsste dass eine der libs in dem File Verwendung findet.





Code::Blocks 12.11 (Nov 25 2012)

CApp.cpp:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "CApp.h"

CApp::CApp()
{
    screen = NULL;
    running = true;
}

int CApp::OnExecute()
{
    if(OnInit() == false)
    {
        return -1;
    }

    SDL_Event event;

    while(running)
    {
        while(SDL_PollEvent(&event))
        {
            OnEvent(&event);
        }
        OnLoop();
        OnRender();
    }
    OnCleanup();

    return 0;
}

int main ( int argc, char** argv )
{
    CApp theApp;
    return theApp.OnExecute();
}


CApp.h:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CAPP_H_INCLUDED
#define CAPP_H_INCLUDED

#include <SDL.h>
#include <SDL_image.h>
#include <string>

#define TITLE "Boxes"
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT   480

class CApp
{
public:
    CApp();
    int OnExecute();
    bool OnInit();
    void OnEvent(SDL_Event* Event);
    void OnExit();
    void OnLoop();
    void OnRender();
    void OnCleanup();

    SDL_Surface *load_image( std::string filename );
private:
    SDL_Surface* screen;
    bool running;
};

#endif // CAPP_H_INCLUDED


CEntity.cpp:


HIER FEHLER!!! (Zeile 3, CEntity::CEntity())

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "CEntity.h"

CEntity::CEntity()
{
    Surf_Entity = NULL;

    pos.x = 0;
    pos.y = 0;

    width = 0;
    height = 0;
    AnimState = 0;
}

bool CEntity::OnLoad(char File)
{
    return true;
}

void CEntity::OnLoop()
{

}

void CEntity::OnRender()
{

}
void CEntity::OnCleanup()
{

}


CEntity.h:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef CENTITY_H_INCLUDED
#define CENTITY_H_INCLUDED

#include <SDL.h>
#include <vector>

#include "types.h"

class CEntity
{
public:
    static std::vector<CEntity*> EntityList;    // Liste der Entities

    position pos;   // Position
    int width; // Breite
    int height; // Höhe

    CEntity();
    virtual ~CEntity();

    //Animation
    int AnimState;  // Aktuelles Bild

    // Funktionen
    virtual bool OnLoad(char File); // Erstellen
    virtual void OnLoop();          // Refresh
    virtual void OnRender();        // Rendern
    virtual void OnCleanup();       // Löschen

protected:
    SDL_Surface* Surf_Entity;   // Surface des Entities
};

#endif // CENTITY_H_INCLUDED


----------------------------------------------------------------------------------------------------------------------------------------
Restlicher Code:


CAppImageload.cpp


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "CApp.h"

SDL_Surface *CApp::load_image( std::string filename )
{
    //The image that's loaded
    SDL_Surface* loadedImage = NULL;

    //The optimized image that will be used
    SDL_Surface* optimizedImage = NULL;

    //Load the image using SDL_image
    loadedImage = IMG_Load( filename.c_str() );

    //If the image loaded
    if( loadedImage != NULL )
    {
        //Create an optimized image
        optimizedImage = SDL_DisplayFormat( loadedImage );

        //Free the old image
        SDL_FreeSurface( loadedImage );
    }

    //Return the optimized image
    return optimizedImage;
}


CAppOnCleanup:

C-/C++-Quelltext

1
2
3
4
5
6
#include "CApp.h"

void CApp::OnCleanup()
{

}


CAppOnEvent:


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "CApp.h"

void CApp::OnEvent(SDL_Event* Event)
{
    switch(Event->type)
    {
        case SDL_QUIT:
        {
            OnExit();
            break;
        }
        case SDL_KEYDOWN:
            if(Event->key.keysym.sym == SDLK_ESCAPE)
            {
                OnExit();
                break;
            }
            if(Event->key.keysym.sym == SDLK_BACKSPACE)
            {

            }
    }
}

void CApp::OnExit()
{
    running = false;
}




CAppOnInit:


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <SDL/SDl.h>

#include "CApp.h"

bool CApp::OnInit()
{
    //Initialize all SDL subsystems
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }

    //Set up the screen
    if((screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL) {
        return false;
    }
    //If there was an error in setting up the screen
    if( screen == NULL )
    {
        return false;
    }

    //Set the window caption
    SDL_WM_SetCaption( TITLE, NULL );

    //If everything initialized fine
    return true;
}




CAppOnRender:


C-/C++-Quelltext

1
2
3
4
5
6
#include "CApp.h"

void CApp::OnRender()
{

}



CAppOnLoop:


C-/C++-Quelltext

1
2
3
4
5
6
#include "CApp.h"

void CApp::OnLoop()
{

}



types.h:


C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
#ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED

typedef struct _position
{
    int x;
    int y;
}position;

#endif // TYPES_H_INCLUDED


NachoMan

Community-Fossil

Beiträge: 3 885

Wohnort: Berlin

Beruf: (Nachhilfe)Lehrer (Mathematik, C++, Java, C#)

  • Private Nachricht senden

2

15.01.2013, 17:44

Der Destructor ist nicht definiert...
"Der erste Trunk aus dem Becher der Erkenntnis macht einem zum Atheist, doch auf dem Grund des Bechers wartet Gott." - Werner Heisenberg
Biete Privatunterricht in Berlin und Online.
Kommt jemand mit Nach oMan?

3

15.01.2013, 17:51

:D Tatsächlich... daran lags... Oh mann darauf hätte ich kommen können :dash: . Vielen Dank dass du mich aus meiner Stundenlange suche gerettet hast xD

Werbeanzeige