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 to"


Sujet :

C++

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre tr�s actif
    Homme Profil pro
    Etudiant en g�nie m�canique
    Inscrit en
    Mars 2011
    Messages
    146
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Etudiant en g�nie m�canique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Par d�faut "Undefined reference to"
    Salut!

    Je n'arrive pas � trouver de cas similaire au mien sur internet, et du coup je suis coinc�.
    En fait, j'ai impl�ment� une classe qui doit utiliser une m�thode pour g�n�rer un facteur, et elle devrait normalement l'utiliser.
    Mais j'ai syst�matiquement (4 fois pour 4 utilisations) la m�me erreur. Je vous montre le code:

    (classe)
    MenuColonneCentree.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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    #ifndef MENUCOLONNECENTREE_H_INCLUDED
    #define MENUCOLONNECENTREE_H_INCLUDED
     
    #include <SFML/Graphics.hpp>
    #include <string>
    #include <vector>
     
    #include "DecoupageQuadratiqueMiroir.h"
     
    using namespace sf;
    using namespace std;
     
     
     
    class MenuColonneCentree
    {   private:
            // Atttributs initialisés par le constructeur
            RenderWindow & window;
     
            // Autres attributs
            Font fonte;
            Color couleur;
            double width, height, hauteurTextePrincipal, hauteurTexteSecondaire, X, j;
            int options, animation, etape, longueurAnimation;
            vector<vector<Text> > texte;
            vector<vector<double> > posX, posY;
     
        public:
            int ligneSelectionnee; // Numéro de la ligne sélectionée (en partant de zéro)
            bool etatAnimation; // Temoin d'animation (true = animation en cours)
            bool etatExistence; // Temoin d'existence (true = objet actif)
     
            MenuColonneCentree(RenderWindow & argWINDOW);
     
            void SetContenu(vector<vector<string> > argCONTENU);
     
            void ChoixAnimation(int argNUMERO);
     
            void MouvementPreselection(int argMOUVEMENT);
     
            void Animation(int argSTEP);
    };
     
    #endif // MENUCOLONNECENTREE_H_INCLUDED
    (classe; erreurs ici)
    MenuColonneCentree.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
    //#define SUIVI
     
    #include <SFML/Graphics.hpp>
     
    #include <windows.h>
    #include <string.h>
    #include <cstdlib>
     
    #ifdef SUIVI
    #include <iostream>
    #endif
     
    #include "MenuColonneCentree.h"
     
    using namespace std;
    using namespace sf;
     
     
     
    // Implémentation des méthodes de la classe
    MenuColonneCentree::MenuColonneCentree(RenderWindow & argWINDOW):
    window(argWINDOW) // Liste d'initialisation
    {   Font fonte; // Fonte pour le texte des menus
        fonte.loadFromFile("Fontes/FonteGVSC.ttf"); // Chargement d'un fichier font
     
        Color couleur; // Couleur pour le texte des menus
        couleur.r=255; couleur.g=100; couleur.b=0; couleur.a=255; // Création d'une couleur (rouge-orangé opaque)
     
        width=VideoMode::getDesktopMode().width; // Récupérer résolution horizontale de l'écran
        height=VideoMode::getDesktopMode().height; // Récupérer résolution verticale de l'écran
     
        hauteurTextePrincipal=height/13;
        hauteurTexteSecondaire=2*height/39;
     
        longueurAnimation=15;
     
        // Présélection par-défaut de l'animation zéro
        animation=4;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, MenuColonneCentree OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::SetContenu(vector<vector<string> > argCONTENU)
    {   // Vider les vecteurs
        texte.clear();
        posX.clear();
        posY.clear();
     
        options=(argCONTENU.size());
     
        ligneSelectionnee=0; // Présélection de la première ligne
     
        for (int index(0); index < options; index++)
        {   texte[index][0].setString(argCONTENU[index][0]);
            texte[index][1].setString(argCONTENU[index][1]);
     
            texte[index][0].setFont(fonte);
            texte[index][1].setFont(fonte);
     
            texte[index][0].setColor(couleur);
            texte[index][1].setColor(couleur);
     
            texte[index][0].setStyle(0);
            texte[index][1].setStyle(0);
     
            posX[index][0]=width/2;
            posX[index][1]=2*width/3;
     
            posY[index][0]=(7-options+2*index)*hauteurTextePrincipal;
            posY[index][1]=(8-options+2*index)*hauteurTextePrincipal;
        }
     
        etatAnimation=false;
        etatExistence=true;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, SetContenu OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::ChoixAnimation(int argNUMERO)
    {   animation=argNUMERO;
     
        switch (animation)
        {   case 0: etatAnimation=true;  break; // Animation standard
            case 1: etatAnimation=false; break; // Entrée en glissant pas la droite
            case 2: etatAnimation=false; break; // Sortie en glissant pas la gauche
            case 3: etatAnimation=false; break; // Sortie en glissant pas la droite
            case 4: etatAnimation=true;  break; // Animation zéro (ne rien faire)
        }
     
        etape=0;
        X=0;
     
        for (int index(0); index < options; index++)
        {   texte[index][index].setCharacterSize(hauteurTextePrincipal);
            texte[index][index].setOrigin(texte[index][index].getGlobalBounds().width/2, hauteurTextePrincipal/2);
     
            texte[index][index+1].setCharacterSize(hauteurTexteSecondaire);
            texte[index][index+1].setOrigin(texte[index][index+1].getGlobalBounds().width/2, hauteurTextePrincipal/2);
        }
     
        etatAnimation=false;
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, ChoixAnimation OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::MouvementPreselection(int argMOUVEMENT)
    {   // argMOUVEMENT : mouvement à effectuer (+ = descendre ; 0 = rester ; - = monter)
     
        ligneSelectionnee+=argMOUVEMENT;
     
        if (ligneSelectionnee > options) {ligneSelectionnee=0;}
        else if (ligneSelectionnee < 0)  {ligneSelectionnee=options;}
     
        #ifdef SUIVI
        cout << "MenuColonneCentree, MouvementPreselection OK" << endl;
        #endif
    }
     
     
     
    void MenuColonneCentree::Animation(int argSTEP)
    {   // argSTEP : nombre d'étapes à passer dans l'animation
     
        etape+=argSTEP; // Incrémenter l'index d'animation
     
        switch (animation)
        {   case 0: // Animation standard de la ligne sélectionnée
                if (etape >= longueurAnimation-1) {etape-=longueurAnimation;} // Ne pas dépasser 14
     
                j=1+DecoupageQuadratiqueMiroir(etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
     
                texte[ligneSelectionnee][0].setCharacterSize(j*hauteurTextePrincipal);
                texte[ligneSelectionnee][1].setCharacterSize(j*hauteurTexteSecondaire);
     
                texte[ligneSelectionnee][0].setOrigin(texte[ligneSelectionnee][0].getGlobalBounds().width/2, j*hauteurTextePrincipal/2);
                texte[ligneSelectionnee][1].setOrigin(texte[ligneSelectionnee][1].getGlobalBounds().width/2, j*hauteurTexteSecondaire/2);
            break;
            case 1: // Entrée en glissant par la droite
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                }
     
                X=width*DecoupageQuadratiqueMiroir(etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
            break;
            case 2: // Sortie en glissant par la gauche
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                    etatExistence=false;
                }
     
                X=width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
            break;
            case 3: // Sortie en glissant par la droite
                if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
                {   etape=longueurAnimation-1;
     
                    etatAnimation=true;
                    etatExistence=false;
                }
     
                X=-width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
            break;
            case 4: // Animation zéro (ne rien faire)
            break;
        }
     
        for (int index(0); index == 2*(options+1); index++)
        {   texte[index][0].setPosition(posX[index][0]+X, posY[index][0]);
            texte[index][1].setPosition(posX[index][1]+X, posY[index][1]);
            window.draw(texte[index][0]);
            window.draw(texte[index][1]);
        }
    }
    (m�thode)
    DecoupageQuadratiqueMiroir.h:
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    #ifndef DECOUPAGEQUADRATIQUEMIROIR_H_INCLUDED
    #define DECOUPAGEQUADRATIQUEMIROIR_H_INCLUDED
     
    using namespace std;
     
    double DecoupageQuadratiqueMiroir(int argETAPE, int argNOMBREETAPES);
     
    #endif // DECOUPAGEQUADRATIQUEMIROIR_H_INCLUDED
    (m�thode)
    DecoupageQuadratiqueMiroir.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
    #include <iostream>
    #include "DecoupageQuadratiqueMiroir.h"
     
    using namespace std;
     
    double DecoupageQuadratiqueMiroir(int argETAPE, int argNOMBREETAPES) // Fonction pour calculer le facteur de dilatation à appliquer en fonction du texte
    {   double dividende(0.0);
        double diviseur(1);
        int index(0);
        int etape(argETAPE);
        int nombreEtapes(argNOMBREETAPES);
     
        while (index < argETAPE)
        {   if (index < argNOMBREETAPES/2)
            {   dividende+=index*index;
     
                index++;
            }
            else if (index == argNOMBREETAPES/2)
            {   index++;
            }
            else if (index > argNOMBREETAPES/2)
            {   index++;
     
                dividende+=(argNOMBREETAPES-index)*(argNOMBREETAPES-index);
            }
        }
     
        diviseur=dividende;
     
        while (index < argNOMBREETAPES)
        {   if (index < argNOMBREETAPES/2)
            {   diviseur+=index*index;
     
                index++;
            }
            else if (index == argNOMBREETAPES/2)
            {   index++;
            }
            else if (index > argNOMBREETAPES/2)
            {   index++;
     
                diviseur+=(argNOMBREETAPES-index)*(argNOMBREETAPES-index);
            }
        }
     
        return dividende/diviseur;
    }
    Et, question subsidiaire: DecoupageQuadratiqueMiroir est-elle le genre de fonctions qu'on peut inliner? (Je demande parce que j'ai aucun feeling �-propos de �a)

    Merci d'avance pour votre aide =)

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    1 415
    D�tails du profil
    Informations personnelles :
    Localisation : France, Paris (�le de France)

    Informations forums :
    Inscription : Mars 2007
    Messages : 1 415
    Par d�faut
    Salut

    Ce n'est pas un probl�me de compilation mais d'�dition de lien. Au moment de g�n�rer l'ex�cutable, le fichier objet (.o) ou la biblioth�que (.a ou .so) qui contient l'impl�mentation de DecoupageQuadratiqueMiroir n'est pas link�. C'est du r�glage de CodeBlocks et pas un probl�me de code. Je ne sais pas comment tu as gaul� ta compilation au juste donc difficile de te dire quoi faire exactement.

  3. #3
    Membre tr�s actif
    Homme Profil pro
    Etudiant en g�nie m�canique
    Inscrit en
    Mars 2011
    Messages
    146
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Etudiant en g�nie m�canique

    Informations forums :
    Inscription : Mars 2011
    Messages : 146
    Par d�faut
    OK... comment est-ce que je peux te montrer comment mon compilateur est param�tr�?

    EDIT: Ah non, stop!

    Le compilateur cherchait "MenuQuestions.h" et "MenuQuestions.cpp", mais je les avais renomm�s en "MenuQuestion.h" et "MenuQuestion.cpp"
    C'est aussi simple que �a =D

  4. #4
    Membre Expert
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    1 415
    D�tails du profil
    Informations personnelles :
    Localisation : France, Paris (�le de France)

    Informations forums :
    Inscription : Mars 2007
    Messages : 1 415
    Par d�faut
    Je dirais que tu as besoin d'apprendre un peu les bases et comprendre au moins au minimum ce que fait une compilation. Tu avances un peu au petit bonheur la chance, tu gagnerais du temps en en prenant pour apprendre.

  5. #5
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ing�nieur d�veloppement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 131
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activit� : Ing�nieur d�veloppement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 131
    Billets dans le blog
    150
    Par d�faut
    Bonjour,

    Ou encore, cette explication (premi�re partie) : http://alexandre-laurent.developpez....-bibliotheque/
    Oh, ne vous ai-je pas demand� de lire le tutoriel, il y a moins d'une semaine
    Vous souhaitez participer � la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui conna�t l'erreur, conna�t la solution.

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. winsock.h : undefined reference...
    Par abraxas dans le forum Dev-C++
    R�ponses: 14
    Dernier message: 06/08/2012, 13h42
  2. Compilation de xmms : undefined reference to...
    Par Micha�l dans le forum Applications et environnements graphiques
    R�ponses: 4
    Dernier message: 04/02/2005, 19h05
  3. undefined reference to `xmlParseFile'
    Par Clemaster dans le forum Autres �diteurs
    R�ponses: 2
    Dernier message: 25/06/2004, 20h38
  4. g++ : undefined reference to ...
    Par le_barbu dans le forum Autres �diteurs
    R�ponses: 16
    Dernier message: 14/05/2004, 07h23

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