IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C++ Discussion :

Undefined reference avec les fonctions d'une class


Sujet :

C++

  1. #1
    Membre actif
    Homme Profil pro
    Inscrit en
    Novembre 2011
    Messages
    97
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 97
    Points : 247
    Points
    247
    Par défaut Undefined reference avec les fonctions d'une class
    Bonjour ou bonsoir,

    En fait je suis en train de faire un petit jeu(sokoban du sdz) en C++ avec la SDL mais dés lors ou j'utilise des class a la place des tableau de int pour gérée le terrain j'ai undifined reference.

    voici les sources(seulement ce qui semble être concerner) :

    jeu.h :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifndef H_JEU
    #define H_JEU
     
        #include "include.h"
        #include "level.h"
        #include "perso.h"
     
        class Jeu
        {
            private :
     
            SDL_Surface *mur, *caisse, *caisse_ok, *cible;
            SDL_Surface *perso[4];
     
            SDL_Rect r_perso;
     
            Level niveau[BLOC_HAUTEUR][BLOC_LARGEUR];
            Perso t;
            bool fini;
     
            public :
     
            Jeu();
            ~Jeu();
     
            bool Init();
            bool Load_Level(std::string filename);
     
            void Show(SDL_Surface* screen);
            void Move(int direction);
            void Verif_fini();
            void Vide_terrain();
        };
     
    #endif
    jeu.cpp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    #include "jeu.h"
     
    Jeu::Jeu()
    {
        int i = 0;
     
        Vide_terrain();
     
        for(i = 0; i < 4; i++)
        {
            perso[i] = NULL;
        }
     
        t.SetDirection(HAUT);
     
        mur = NULL;
        caisse = NULL;
        caisse_ok = NULL;
        cible = NULL;
     
        fini = false;
    }
     
    Jeu::~Jeu()
    {
        int i = 0;
     
        for(i = 0; i < 4; i++)
        {
            SDL_FreeSurface(perso[i]);
        }
     
        SDL_FreeSurface(mur);
        SDL_FreeSurface(caisse);
        SDL_FreeSurface(caisse_ok);
        SDL_FreeSurface(cible);
    }
     
    bool Jeu::Init()
    {
        int i = 0, j = 0;
     
        if(!(Load_Level("Level/test.map")))
        {
            return false;
        }
     
        mur = SDL_LoadBMP("Image/mur.bmp");
        caisse = SDL_LoadBMP("Image/caisse.bmp");
        caisse_ok = SDL_LoadBMP("Image/caisse_ok.bmp");
        cible = SDL_LoadBMP("Image/cible.bmp");
     
        for(i = 0; i < BLOC_HAUTEUR; i++)
        {
            for(j = 0; j < BLOC_LARGEUR; j++)
            {
                niveau[i][j].SetImage(mur, caisse, caisse_ok, cible);
            }
        }
     
        perso[HAUT] = SDL_LoadBMP("Image/perso_haut.bmp");
        perso[BAS] = SDL_LoadBMP("Image/perso_bas.bmp");
        perso[DROITE] = SDL_LoadBMP("Image/perso_droite.bmp");
        perso[GAUCHE] = SDL_LoadBMP("Image/perso_gauche.bmp");
     
        for(i = 0; i < 4; i++)
        {
            SDL_SetColorKey(perso[i], SDL_SRCCOLORKEY, SDL_MapRGB(perso[i]->format, 255, 255, 255));
     
            if(perso[i] == NULL)
            {
                std::cout << "Impossible de charger les images du perso" << std::endl;
     
                return false;
            }
        }
     
        t.SetImage(perso[HAUT], perso[BAS], perso[DROITE], perso[GAUCHE]);
     
        if((mur == NULL) || (caisse == NULL) || (caisse_ok == NULL) || (cible == NULL))
        {
            std::cout << "Impossible de charger l'image du mur, des caisses et de la cible" << std::endl;
     
            return false;
        }
     
        for(i = 0; i < BLOC_HAUTEUR; i++)
        {
            for(j = 0; j < BLOC_LARGEUR; j++)
            {
                if(niveau[i][j].GetType() == PERSO)
                {
                    r_perso.x = j;
                    r_perso.y = i;
                }
            }
        }
     
        t.SetPos(&r_perso);
     
        return true;
    }
     
    bool Jeu::Load_Level(std::string filename)
    {
        std::ifstream file(filename.c_str());
        char c;
     
        int i = 0, j = 0;
     
        if(file)
        {
            for(i = 0; i < BLOC_HAUTEUR; i++)
            {
                for(j = 0; j < BLOC_LARGEUR; j++)
                {
                    file.get(c);
     
                    niveau[i][j].SetType(c - '0');
                }
            }
        }
        else
        {
            std::cout << "Impossible de charger le niveau" << std::endl;
     
            return false;
        }
     
        return true;
    }
     
    void Jeu::Show(SDL_Surface* screen)
    {
        SDL_Rect r_dest;
     
        int i = 0, j = 0;
     
        for(i = 0; i < BLOC_HAUTEUR; i++)
        {
            for(j = 0; j < BLOC_LARGEUR; j++)
            {
                r_dest.x = j * TAILLE_IMAGE;
                r_dest.y = i * TAILLE_IMAGE;
     
                niveau[i][j].SetPos(&r_dest);
                niveau[i][j].Show(screen);
            }
        }
     
        r_dest.x = r_perso.x * TAILLE_IMAGE;
        r_dest.y = r_perso.y * TAILLE_IMAGE;
     
        t.SetPos(&r_dest);
        t.Show(screen);
    }
     
    void Jeu::Move(int direction)
    {
        switch(direction)
        {
            case HAUT :
                t.SetDirection(HAUT);
     
                if(t.GetPosY() -1 < 0)
                {
                    break;
                }
     
                if(niveau[t.GetPosY() -1][t.GetPosX()].CompType(MUR))
                {
                    break;
                }
     
                if(((niveau[t.GetPosY() -1][t.GetPosX()].CompType(CAISSE)) || (niveau[t.GetPosY() -1][t.GetPosX()].CompType(CAISSE_OK)))
                && ((niveau[t.GetPosY() -2][t.GetPosX()].CompType(MUR)) || (niveau[t.GetPosY() -2][t.GetPosX()].CompType(CAISSE)) || (niveau[t.GetPosY() -2][t.GetPosX()].CompType(CAISSE_OK))))
                {
                    break;
                }
     
                t.PousseCaisse(niveau[t.GetPosY() -1][t.GetPosX()], niveau[t.GetPosY() -2][t.GetPosX()]);
     
                r_perso.y -= 1;
            break;
     
            case BAS :
                t.SetDirection(BAS);
     
                if(t.GetPosY() +1 < 0)
                {
                    break;
                }
     
                if(niveau[t.GetPosY() +1][t.GetPosX()].CompType(MUR))
                {
                    break;
                }
     
                if(((niveau[t.GetPosY() +1][t.GetPosX()].CompType(CAISSE)) || (niveau[t.GetPosY() +1][t.GetPosX()].CompType(CAISSE_OK)))
                && ((niveau[t.GetPosY() +2][t.GetPosX()].CompType(MUR)) || (niveau[t.GetPosY() +2][t.GetPosX()].CompType(CAISSE)) || (niveau[t.GetPosY() +2][t.GetPosX()].CompType(CAISSE_OK))))
                {
                    break;
                }
     
                t.PousseCaisse(niveau[t.GetPosY() +1][t.GetPosX()], niveau[t.GetPosY() +2][t.GetPosX()]);
     
                r_perso.y += 1;
            break;
     
            case DROITE :
                t.SetDirection(DROITE);
     
                if(t.GetPosX() +1 < 0)
                {
                    break;
                }
     
                if(niveau[t.GetPosY()][t.GetPosX() +1].CompType(MUR))
                {
                    break;
                }
     
                if(((niveau[t.GetPosY()][t.GetPosX() +1].CompType(CAISSE)) || (niveau[t.GetPosY()][t.GetPosX() +1].CompType(CAISSE_OK)))
                && ((niveau[t.GetPosY()][t.GetPosX() +2].CompType(MUR)) || (niveau[t.GetPosY()][t.GetPosX() +2].CompType(CAISSE)) || (niveau[t.GetPosY()][t.GetPosX() +2].CompType(CAISSE_OK))))
                {
                    break;
                }
     
                t.PousseCaisse(niveau[t.GetPosY()][t.GetPosX() +1], niveau[t.GetPosY()][t.GetPosX() +2]);
     
                r_perso.x += 1;
            break;
     
            case GAUCHE :
                t.SetDirection(GAUCHE);
     
                if(t.GetPosX() -1 < 0)
                {
                    break;
                }
     
                if(niveau[t.GetPosY()][t.GetPosX() -1].CompType(MUR))
                {
                    break;
                }
     
                if(((niveau[t.GetPosY()][t.GetPosX() -1].CompType(CAISSE)) || (niveau[t.GetPosY()][t.GetPosX() -1].CompType(CAISSE_OK)))
                && ((niveau[t.GetPosY()][t.GetPosX() -2].CompType(MUR)) || (niveau[t.GetPosY()][t.GetPosX() -2].CompType(CAISSE)) || (niveau[t.GetPosY()][t.GetPosX() -2].CompType(CAISSE_OK))))
                {
                    break;
                }
     
                t.PousseCaisse(niveau[t.GetPosY()][t.GetPosX() -1], niveau[t.GetPosY()][t.GetPosX() -2]);
     
                r_perso.x -= 1;
            break;
     
            default :
            break;
        }
    }
     
    void Jeu::Verif_fini()
    {
        int i = 0, j = 0;
     
        for(i = 0; i < BLOC_HAUTEUR; i++)
        {
            for(j = 0; j < BLOC_LARGEUR; j++)
            {
                if((niveau[i][j].CompType(CAISSE)) || (niveau[i][j].CompType(CIBLE)))
                {
                    fini = true;
                }
                else
                {
                    fini = false;
                }
            }
        }
    }
     
    void Jeu::Vide_terrain()
    {
        int i = 0, j = 0;
     
        for(i = 0; i < BLOC_HAUTEUR; i++)
        {
            for(j = 0; j < BLOC_LARGEUR; j++)
            {
                niveau[i][j].SetType(VIDE);
            }
        }
    }
    level.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifndef H_LEVEL
    #define H_LEVEL
     
        #include "include.h"
     
        class Level
        {
            private :
     
            std::vector<SDL_Surface*> image;
     
            int curimage;
     
            Bloc type;
     
            SDL_Rect pos;
     
            public :
     
            Level();
            ~Level();
     
            void Init();
            void SetPos(SDL_Rect* p);
            void SetImage(SDL_Surface* mur, SDL_Surface* caisse, SDL_Surface* caisse_ok, SDL_Surface* cible);
            void Show(SDL_Surface* screen);
            void SetType(int t);
     
            bool GetClic(int x, int y);
            bool CompType(Bloc bloc);
     
            Bloc GetType();
        };
     
    #endif
    level.cpp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    #include "level.h"
     
    Level::Level()
    {
        int i = 0;
     
        image.resize(4);
     
        for(i = 0; i < 4; i++)
        {
            image[i] = NULL;
        }
     
        curimage = 0;
     
        pos.h = 0;
        pos.w = 0;
        pos.x = 0;
        pos.y = 0;
    }
     
    Level::~Level()
    {
     
    }
     
    void Level::Init()
    {
        curimage = 0;
        type = VIDE;
    }
     
    void Level::SetPos(SDL_Rect* p)
    {
        pos = *p;
    }
     
    void Level::SetImage(SDL_Surface* mur, SDL_Surface* caisse, SDL_Surface* caisse_ok, SDL_Surface* cible)
    {
        image[0] = mur;
        image[1] = caisse;
        image[2] = caisse_ok;
        image[3] = cible;
    }
     
    void Level::Show(SDL_Surface* screen)
    {
        if(image[curimage])
        {
            SDL_BlitSurface(image[curimage], NULL, screen, &pos);
        }
    }
     
    bool Level::GetClic(int x, int y)
    {
        return ((x > pos.x) && (x < pos.x + pos.w) && (y > pos.y) && (y < pos.y + pos.h));
    }
     
    Bloc Level::GetType()
    {
        return type;
    }
     
    void Level::SetType(int t)
    {
        switch(t)
        {
            case MUR :
                curimage = 0;
            break;
     
            case CAISSE :
                curimage = 1;
            break;
     
            case CAISSE_OK :
                curimage = 2;
            break;
     
            case CIBLE :
                curimage = 3;
            break;
     
            default :
                curimage = -1;
            break;
        }
    }
     
    bool Level::CompType(Bloc bloc)
    {
        return bloc == type;
    }
    perso.h :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifndef H_PERSO
    #define H_PERSO
     
        #include "include.h"
        #include "level.h"
     
        class Perso
        {
            private :
     
            std::vector<SDL_Surface*> image;
     
            int curimage;
     
            SDL_Rect pos;
     
            public :
     
            Perso();
            ~Perso();
     
            void Init();
            void SetImage(SDL_Surface* p_haut, SDL_Surface* p_bas, SDL_Surface* p_droite, SDL_Surface* p_gauche);
            void SetPos(SDL_Rect* p);
            void SetDirection(int direction);
            void Show(SDL_Surface* screen);
            void PousseCaisse(Level &bloc1, Level &bloc2);
     
            int GetPosX();
            int GetPosY();
        };
     
    #endif
    perso.cpp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    #include "perso.h"
    #include "level.h"
     
    Perso::Perso()
    {
        int i = 0;
     
        image.resize(4);
     
        for(i = 0; i < 4; i++)
        {
            image[i] = NULL;
        }
     
        curimage = 0;
     
        pos.h = 0;
        pos.w = 0;
        pos.x = 0;
        pos.y = 0;
    }
     
    void Perso::Init()
    {
        curimage = 0;
    }
     
    void Perso::SetImage(SDL_Surface* p_haut, SDL_Surface* p_bas, SDL_Surface* p_droite, SDL_Surface* p_gauche)
    {
        image[HAUT] = p_haut;
        image[BAS] = p_bas;
        image[DROITE] = p_droite;
        image[GAUCHE] = p_gauche;
    }
     
    void Perso::SetPos(SDL_Rect* p)
    {
        pos = *p;
    }
     
    void Perso::SetDirection(int direction)
    {
        curimage = direction;
    }
     
    void Perso::Show(SDL_Surface* screen)
    {
        if(image[curimage])
        {
            SDL_BlitSurface(image[curimage], NULL, screen, &pos);
        }
    }
     
    void Perso::PousseCaisse(Level &bloc1, Level &bloc2)
    {
        if((bloc1.CompType(CAISSE)) || (bloc1.CompType(CAISSE_OK)))
        {
            if(bloc2.CompType(CIBLE))
            {
                bloc2.SetType(CAISSE_OK);
            }
            else
            {
                bloc2.SetType(CAISSE);
            }
     
            if(bloc1.CompType(CAISSE_OK))
            {
                bloc1.SetType(CIBLE);
            }
            else
            {
                bloc1.SetType(VIDE);
            }
        }
    }
     
    int Perso::GetPosX()
    {
        return pos.x;
    }
     
    int Perso::GetPosY()
    {
        return pos.y;
    }
    J'èspere que vous pourriez m'aider.

  2. #2
    Membre actif Avatar de Rewpparo
    Homme Profil pro
    Amateur
    Inscrit en
    Décembre 2005
    Messages
    170
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Amateur

    Informations forums :
    Inscription : Décembre 2005
    Messages : 170
    Points : 281
    Points
    281
    Par défaut
    Citation Envoyé par romnair Voir le message
    dés lors ou j'utilise des class a la place des tableau de int pour gérée le terrain j'ai undifined reference.
    Laquelle ?

  3. #3
    Membre actif
    Homme Profil pro
    Inscrit en
    Novembre 2011
    Messages
    97
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 97
    Points : 247
    Points
    247
    Par défaut ?
    A, désolé je te donne les erreurs :
    ||=== Sokoban, Debug ===|
    obj/Debug/jeu.o||In function `Jeu'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|3|undefined reference to `Level::Level()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|3|undefined reference to `Level::~Level()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|3|undefined reference to `Level::~Level()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|3|undefined reference to `Perso::~Perso()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|3|undefined reference to `Level::~Level()'|
    obj/Debug/jeu.o||In function `~Jeu'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|24|undefined reference to `Perso::~Perso()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|24|undefined reference to `Level::~Level()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|24|undefined reference to `Perso::~Perso()'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|24|undefined reference to `Level::~Level()'|
    obj/Debug/jeu.o||In function `Jeu::Init()'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|57|undefined reference to `Level::SetImage(SDL_Surface*, SDL_Surface*, SDL_Surface*, SDL_Surface*)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|91|undefined reference to `Level::GetType()'|
    obj/Debug/jeu.o||In function `Jeu::Load_Level(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|119|undefined reference to `Level::SetType(int)'|
    obj/Debug/jeu.o||In function `Jeu::Show(SDL_Surface*)'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|146|undefined reference to `Level::SetPos(SDL_Rect*)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|147|undefined reference to `Level::Show(SDL_Surface*)'|
    obj/Debug/jeu.o||In function `Jeu::Move(int)'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|170|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|175|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|175|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|176|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|176|undefined reference to `Level::CompType(Bloc)'|
    obj/Debug/jeu.o:/home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|176|more undefined references to `Level::CompType(Bloc)' follow|
    obj/Debug/jeu.o||In function `Jeu::Vide_terrain()'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/jeu.cpp|291|undefined reference to `Level::SetType(int)'|
    obj/Debug/perso.o||In function `Perso:ousseCaisse(Level&, Level&)'
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|56|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|56|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|58|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|60|undefined reference to `Level::SetType(int)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|64|undefined reference to `Level::SetType(int)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|67|undefined reference to `Level::CompType(Bloc)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|69|undefined reference to `Level::SetType(int)'|
    /home/romain/Documents/CB Project/SDL/Game Project/Sokoban/perso.cpp|73|undefined reference to `Level::SetType(int)'|
    ||=== Build finished: 29 errors, 0 warnings ===|

  4. #4
    Membre éprouvé

    Profil pro
    Inscrit en
    Décembre 2008
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2008
    Messages : 533
    Points : 1 086
    Points
    1 086
    Par défaut
    Tu as probablement oublié d'ajouter (Project > Add_files...) à ton projet les fichiers level.cpp et perso.cpp.
    Ou peut-être qu'ils n'ont été ajoutés que pour le mode Release.

    Du coup Code::Blocks les ignore, leurs .o respectifs ne sont pas créés et donc toutes les fonctions de Level et Perso auquelles Jeu fait référence sont considérées comme non-définies. D'où undefined reference.

  5. #5
    Membre actif Avatar de Rewpparo
    Homme Profil pro
    Amateur
    Inscrit en
    Décembre 2005
    Messages
    170
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Amateur

    Informations forums :
    Inscription : Décembre 2005
    Messages : 170
    Points : 281
    Points
    281
    Par défaut
    En gros tout quoi Ca veut dire que tu ne compiles pas tes fichiers .cpp
    Si tu es avec visual studio, vérifie qu'ils sont bien dans ton projet.
    Si tu es avec g++, mets bien tous les .cpp dans la commande de compilation.

  6. #6
    Membre actif
    Homme Profil pro
    Inscrit en
    Novembre 2011
    Messages
    97
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 97
    Points : 247
    Points
    247
    Par défaut
    Merci pour vos réponse c'était bien ça.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Un tableau associatif avec les éléments d'une classe
    Par renaud26 dans le forum jQuery
    Réponses: 2
    Dernier message: 29/11/2011, 06h07
  2. Question convention avec les attributs d'une classe
    Par pierrehs dans le forum Langage
    Réponses: 2
    Dernier message: 06/06/2011, 14h55
  3. probleme avec les methodes dans une class
    Par artemis93 dans le forum Débuter avec Java
    Réponses: 4
    Dernier message: 02/05/2011, 12h33
  4. [Système] Problème avec les méthodes d'une classe
    Par oussama127 dans le forum Langage
    Réponses: 7
    Dernier message: 30/08/2006, 09h18
  5. Réponses: 4
    Dernier message: 10/02/2005, 16h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo