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 :

[Aux etudes]Probleme de link


Sujet :

C++

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre à l'essai
    Inscrit en
    Novembre 2006
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 4
    Par défaut [Aux etudes]Probleme de link
    Bonjour,
    J'ai un problème de link plus que frustrant... Je cherche un solution depuis plusieurs heures déjà et je ne vois aucune erreur... Probablement parce que je cherche

    Voici donc, j'ai une bilbiothèque "Rectangle" qui manipule des rectangles ainsi qu'une seconde bibliotheque 'en construction' nommé "TableauRectangle" qui, vous le devinez, manipule des tableaux de rectangle.

    Dans le dossier de solution j'ai :
    -Debug (Dossier)
    -Principal.cpp (fichier contenant le main)
    -Rectangle.h (.h de la bibliotheque Rectangle)
    -TableauRectangle.cpp (fichier contenant le code de la bibliotheque TableauRectangle)
    -TableauRectangle.h (.h de la bilbiothque TableauRectangle)
    -TableauRectangle.vcproj

    Dans le dossier Debug :
    -...plein de truc
    -Principal.obj
    -TableauRectangle.obj
    -Rectangle.obj
    -...plein d'autre truc

    Principal.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
     
    //
    // Principal.cpp
    // Francis Mireault
    // 27 / 11 / 2006
    // But : Test de la bibliotheque TableauRectangle
    //
     
    #include <iostream>
    using namespace std ;
    #include "TableauRectangle.h"
     
    int main ()
    {
       const int MAX_ELEMENTS = 2 ;
       Rectangle Tableau [MAX_ELEMENTS] ;
       LireElements(Tableau, MAX_ELEMENTS) ;
    }
    Rectangle.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
     
    #ifndef RECTANGLE_H
    #define RECTANGLE_H
     
    //
    // Rectangle.h
    // Francis Mireault
    // 27 / 11 / 2006
    // But : Interface de la bibliotheque Rectangle
    //
     
    struct Rectangle
    {
       int m_Largeur ;
       int m_Hauteur ;
       char m_Contour ;
       char m_Milieu ;
    } ;
     
    // Fonction LireRectangle ()
    // Intrants :  (aucun)
    // Extrants :  Un rectangle (Rectangle UnRectangle)
    // Role : Lecture d'un rectangle (de toutes ses donnees)
    Rectangle LireRectangle () ;
     
    // Fonction  Afficher ()
    // Intrants :   Un rectangle (Rectangle &UnRectangle)
    // Extrants :   (aucun)
    // Role : Afficher un rectangle a l'ecran
    void Afficher (Rectangle &UnRectangle) ;
     
    // Fonction EstPlusPetit (const Rectangle &Rectangle1, const Rectangle &Rectangle2)
    // Intrants :  Un rectangle (const Rectangle &Rectangle1)
    //             Un autre rectangle (const Rectangle &Rectangle2)
    // Extrants :  Est plus petit (bool EstPlusPetit)
    // Role : Determine si le premier rectangle est le plus petit
    bool EstPlusPetit (const Rectangle &Rectangle1, const Rectangle &Rectangle2) ;
     
    #endif
    Rectangle.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
     
    //
    // Rectangle.h
    // Francis Mireault
    // 27 / 11 / 2006
    // But : Interface de la bibliotheque Rectangle
    //
     
    #include <iostream>
    using namespace std ;
     
    struct Rectangle
    {
       int m_Largeur ;
       int m_Hauteur ;
       char m_Contour ;
       char m_Milieu ;
    } ;
     
    // Fonction CreerRectangle (int Largeur, int Hauteur, char CaracContour, char CaracMilieu)
    // Intrants :  Largeur du rectangle (int Largeur)
    //             Hauteur du rectangle (int Hauteur)
    //             Caractere de contour du rectangle (char CaracContour)
    //             Caractere du milieu du rectangle (char CaracMilieu)
    // Extrants :  Un rectangle (Rectangle UnRectangle)
    // Role : Creer un rectangle avec ses differents attributs
    Rectangle CreerRectangle (int Largeur, int Hauteur, char CaracContour, char CaracMilieu) ;
     
    // Fonction SetLargeur(int Largeur)
    // Intrants :  Une largeur (int Largeur)
    // Extrants :  Une largeur valide (int LargeurValide)
    // Role : S'assurer de la validité de la largeur
    int SetLargeur (int Largeur) ;
     
    // Fonction SetHauteur(int Hauteur)
    // Intrants :  Une hauteur (int Hauteur)
    // Extrants :  Une hauteur valide (int HauteurValide)
    // Role : S'assurer de la validité de la hauteur
    int SetHauteur (int Hauteur) ;
     
    // Fonction EcrireLigne (const char CaracContour, const char CaracMilieu, const short NbCaracAEcrire, const short NumLigne, const short MaxLigne)
    // Intrants :  Caractere de contour (const char CaracContour)
    //             Caractere du milieu (const char CaracMilieu)
    //             Nombre de caractere a ecrire (const short NbCaracAEcrire)
    //             Numero de la ligne (const short NumLigne)
    //             Le maximum de la ligne (const short MaxLigne)
    // Extrants :  (aucun)
    // Role : Ecrire une ligne d'un rectangle
    void EcrireLigne (const char CaracContour, const char CaracMilieu, const short NbCaracAEcrire, const short NumLigne, const short MaxLigne) ;
     
    // Fonction AfficherCaractere (const char CaracContour, const char CaracMilieu, const short NumColonne, const short MaxColonne, const short NumLigne, const short MaxLigne)
    // Intrants :  Caractere de contour (const char CaracContour)
    //             Caractere du milieu (const char CaracMilieu)
    //             Numero de la colonne (const short NumColonne)
    //             Maximum de la colonne (const short MaxColonne)
    //             Numero de la ligne (const short NumLigne)
    //             Le maximum de la ligne (const short MaxLigne)
    // Extrants :  (aucun)
    // Role : Afficher un caractere d'une ligne
    void AfficherCaractere (const char CaracContour, const char CaracMilieu, const short NumColonne, const short MaxColonne, const short NumLigne, const short MaxLigne) ;
     
    //
    // DEBUT CONSTANTES GLOBALES
    //
    const short MIN_LARGEUR = 3 ;
    const short MAX_LARGEUR = 30 ;
    const short MIN_HAUTEUR = 3 ;
    const short MAX_HAUTEUR = 20 ;
     
    //
    // FIN CONSTANTES GLOBALES
    //
     
    // Fonction LireRectangle ()
    // Intrants :  (aucun)
    // Extrants :  Un rectangle (Rectangle UnRectangle)
    // Role : Lecture d'un rectangle (de toutes ses donnees)
    Rectangle LireRectangle ()
    {
       int Largeur ;
       int Hauteur ;
       char CaracContour ;
       char CaracMilieu ;
       // Lecture des elements necessaires a la creation du rectangle
       cout << "Largeur (entre "
            << MIN_LARGEUR
            << " et "
            << MAX_LARGEUR
            << ") : " ;
       cin >> Largeur ;
       cout << "Hauteur (entre "
            << MIN_HAUTEUR
            << " et "
            << MAX_HAUTEUR
            << ") : " ;
       cin >> Hauteur ;
       cout << "Caractere de contour : " ;
       cin >> CaracContour ;
       cout << "Caractere du milieu : " ;
       cin >> CaracMilieu ;
       return CreerRectangle (Largeur, Hauteur, CaracContour, CaracMilieu) ;
    }
    // Fonction CreerRectangle (int Largeur, int Hauteur, char CaracContour, char CaracMilieu)
    // Intrants :  Largeur du rectangle (int Largeur)
    //             Hauteur du rectangle (int Hauteur)
    //             Caractere de contour du rectangle (char CaracContour)
    //             Caractere du milieu du rectangle (char CaracMilieu)
    // Extrants :  Un rectangle (Rectangle UnRectangle)
    // Role : Creer un rectangle avec ses differents attributs
    Rectangle CreerRectangle (int Largeur, int Hauteur, char CaracContour, char CaracMilieu)
    {
       Rectangle UnRectangle ;
       UnRectangle.m_Largeur = SetLargeur(Largeur) ;
       UnRectangle.m_Hauteur = SetHauteur(Hauteur) ;
       UnRectangle.m_Contour = CaracContour ;
       UnRectangle.m_Milieu = CaracMilieu ;
       return UnRectangle ;
    }
    // Fonction SetLargeur(int Largeur)
    // Intrants :  Une largeur (int Largeur)
    // Extrants :  Une largeur valide (int LargeurValide)
    // Role : S'assurer de la validité de la largeur
    int SetLargeur (int Largeur)
    {
       const int LARGEUR_DEFAUT = 3 ;
       int LargeurValide ;
       if (Largeur >= MIN_LARGEUR && Largeur <= MAX_LARGEUR)
       {
          LargeurValide = Largeur ;
       }
       else
       {
          LargeurValide = LARGEUR_DEFAUT ;
       }
       return LargeurValide ;
    }
    // Fonction SetHauteur(int Hauteur)
    // Intrants :  Une hauteur (int Hauteur)
    // Extrants :  Une hauteur valide (int HauteurValide)
    // Role : S'assurer de la validité de la hauteur
    int SetHauteur (int Hauteur)
    {
       const int HAUTEUR_DEFAUT = 3 ;
       int HauteurValide ;
       if (Hauteur >= MIN_HAUTEUR && Hauteur <= MAX_HAUTEUR)
       {
          HauteurValide = Hauteur ;
       }
       else
       {
          HauteurValide = HAUTEUR_DEFAUT ;
       }
       return HauteurValide ;
    }
    // Fonction  Afficher ()
    // Intrants :   Un rectangle (Rectangle &UnRectangle)
    // Extrants :   (aucun)
    // Role : Afficher un rectangle a l'ecran
    void Afficher (Rectangle &UnRectangle)
    {
       short CptLignes = 1 ;
       while (CptLignes <= UnRectangle.m_Hauteur)
       {
          EcrireLigne (UnRectangle.m_Contour, UnRectangle.m_Milieu, UnRectangle.m_Largeur, CptLignes, UnRectangle.m_Hauteur) ;
          cout << endl ;
          ++CptLignes ;
       }
    }
    // Fonction EcrireLigne (const char CaracContour, const char CaracMilieu, const short NbCaracAEcrire, const short NumLigne, const short MaxLigne)
    // Intrants :  Caractere de contour (const char CaracContour)
    //             Caractere du milieu (const char CaracMilieu)
    //             Nombre de caractere a ecrire (const short NbCaracAEcrire)
    //             Numero de la ligne (const short NumLigne)
    //             Le maximum de la ligne (const short MaxLigne)
    // Extrants :  (aucun)
    // Role : Ecrire une ligne d'un rectangle
    void EcrireLigne (const char CaracContour, const char CaracMilieu, const short NbCaracAEcrire, const short NumLigne, const short MaxLigne)
    {
       short CptCarac = 1 ;
       while (CptCarac <= NbCaracAEcrire)
       {
          AfficherCaractere (CaracContour, CaracMilieu, CptCarac, NbCaracAEcrire, NumLigne, MaxLigne) ;
          ++CptCarac ;
       }
    }
    // Fonction AfficherCaractere (const char CaracContour, const char CaracMilieu, const short NumColonne, const short MaxColonne, const short NumLigne, const short MaxLigne)
    // Intrants :  Caractere de contour (const char CaracContour)
    //             Caractere du milieu (const char CaracMilieu)
    //             Numero de la colonne (const short NumColonne)
    //             Maximum de la colonne (const short MaxColonne)
    //             Numero de la ligne (const short NumLigne)
    //             Le maximum de la ligne (const short MaxLigne)
    // Extrants :  (aucun)
    // Role : Afficher un caractere d'une ligne
    void AfficherCaractere (const char CaracContour, const char CaracMilieu, const short NumColonne, const short MaxColonne, const short NumLigne, const short MaxLigne)
    {
       const short PREMIERE_COLONNE = 1 ;
       const short PREMIERE_LIGNE = 1 ;
       if (NumColonne == PREMIERE_COLONNE || NumColonne == MaxColonne || NumLigne == PREMIERE_LIGNE || NumLigne == MaxLigne)
       {
          cout << CaracContour ;
       }
       else
       {
          cout << CaracMilieu ;
       }
    }
     
    // Fonction EstPlusPetit (const Rectangle &Rectangle1, const Rectangle &Rectangle2)
    // Intrants :  Un rectangle (const Rectangle &Rectangle1)
    //             Un autre rectangle (const Rectangle &Rectangle2)
    // Extrants :  Est plus petit (bool EstPlusPetit)
    // Role : Determine si le premier rectangle est le plus petit
    bool EstPlusPetit (const Rectangle &Rectangle1, const Rectangle &Rectangle2)
    {
       return (Rectangle1.m_Hauteur * Rectangle1.m_Hauteur < Rectangle2.m_Largeur * Rectangle2.m_Hauteur) ;
    }
    TableauRectangle.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
     
    #ifndef TABLEAU_RECTANGLE_H
    #define TABLEAU_RECTANGLE_H
     
    //
    // TableauRectangle.cpp
    // Francis Mireault
    // 27 / 11 / 2006
    // But : Interface de la bibliotheque TableauRectangle
    //
     
    #include "Rectangle.h"
     
    // Fonction LireElements (Rectangle T_Val[], const int MaxElements)
    // Intrants :  Un tableau de rectangle (Rectangle T_Val[])
    //             Le nombre d'element du tableau (const int MaxElements)
    // Extrants :  Un tableau de rectangle (Rectangle T_Val[])
    // Role : Assure la lecture d'un tableau de rectangle
    void LireElements (Rectangle T_Val[], const int MaxElements) ;
     
    // Fonction TrierTableau (Rectangle T_Val[], const int MaxElements)
    // Intrants :  Un tableau de rectangle (Rectangle T_Val[])
    //             Le nombre d'element du tableau (const int MaxElements)
    // Extrants :  Un tableau de rectangle (Rectangle T_Val[])
    // Role : Trier les elements du tableau
    void TrierTableau (Rectangle T_Val[], const int MaxElements) ;
     
    // Fonction AfficherCroissant (const Rectangle T_Val[], const int MaxElements)
    // Intrants :  Un tableau de rectangle (const Rectangle T_Val[])
    //             Le nombre d'element du tableau (const int MaxElements)
    // Extrants :  Un tableau de rectangle (const Rectangle T_Val[])
    // Role : Afficher les elements du tableau en ordre croissant selon la surface
    void AfficherCroissant (const Rectangle T_Val[], const int MaxElements) ;
     
    // Fonction AfficherDecroissant (const Rectangle T_Val[], const int MaxElements)
    // Intrants :  Un tableau de rectangle (const Rectangle T_Val[])
    //             Le nombre d'element du tableau (const int MaxElements)
    // Extrants :  Un tableau de rectangle (const Rectangle T_Val[])
    // Role : Afficher les elements du tableau en ordre decroissant selon la surface
    void AfficherDecroissant (const Rectangle T_Val[], const int MaxElements) ;
     
    #endif
    TableauRectangle.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
     
    //
    // TableauRectangle.cpp
    // Francis Mireault
    // 27 / 11 / 2006
    // But : Implementation de la bibliotheque TableauRectangle
    //
     
    #include <iostream>
    using namespace std ;
    #include "Rectangle.h"
     
    // Fonction LireElements (Rectangle T_Val[], const int MaxElement)
    // Intrants :  Un tableau de rectangle (Rectangle T_Val[])
    //             Le nombre d'element du tableau (const int MaxElement)
    // Extrants :  Un tableau de rectangle (Rectangle T_Val[])
    // Role :   Assure la lecture d'un tableau de rectangle
    void LireElements (Rectangle Tableau[], const int MaxElements)
    {
       int i ;
       for (i = 0 ; i < MaxElements ; ++i)
       {
          cout << "Rectangle #"
               << i + 1 ;
     
          Rectangle Test = LireRectangle () ;
          cout << endl ;
       }
       cout << endl ;
    }
    Et l'erreur :

    1>------ Début de la génération : Projet : TableauRectangle, Configuration : Debug Win32 ------
    1>Compilation en cours...
    1>Principal.cpp
    1>Édition des liens en cours...
    1>TableauRectangle.obj : error LNK2019: unresolved external symbol "struct Rectangle __cdecl LireRectangle(void)" (?LireRectangle@@YA?AURectangle@@XZ) referenced in function "void __cdecl LireElements(struct Rectangle * const,int)" (?LireElements@@YAXQAURectangle@@H@Z)
    1>C:\Études\CLG\Session 1\ka0\TableauRectangle\Debug\TableauRectangle.exe : fatal error LNK1120: 1 unresolved externals
    1>Le journal de génération a été enregistré à l'emplacement "file://c:\Études\CLG\Session 1\ka0\TableauRectangle\TableauRectangle\Debug\BuildLog.htm"
    1>TableauRectangle - 2 erreur(s), 0 avertissement(s)
    ========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

    Aider-moi s'il vous plaît... tout semble en place, mais on dirait qu'il ne trouve pas la fonction présente dans le fichier Rectangle.h

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    194
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 194
    Par défaut
    tu ne compiles que principal.cpp...
    tu dois inclure les 3 .cpp dans ton projets

  3. #3
    Membre à l'essai
    Inscrit en
    Novembre 2006
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 4
    Par défaut
    Mais étant donné que j'inclus TableauRectangle.h qui lui même contient Rectangle.h, ce serait supposé fonctionné comme si les bibliothèque était des bibliothèque déja compiler et que je n'ai que le .h et le .obj, non ?!?!

  4. #4
    Membre à l'essai
    Inscrit en
    Novembre 2006
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 4
    Par défaut
    Bon bon...
    Laissé faire j'ai trouvé...
    J'avais oublier d'inclure Rectangle.obj au projet....

    Merci quand même

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

Discussions similaires

  1. probleme de link
    Par Volazara dans le forum MFC
    Réponses: 1
    Dernier message: 22/12/2005, 14h26
  2. [MFC]probleme de link
    Par benahpets dans le forum MFC
    Réponses: 4
    Dernier message: 12/08/2005, 09h56
  3. [newbie][virtual] probleme de link
    Par BainE dans le forum MFC
    Réponses: 1
    Dernier message: 01/06/2005, 17h21
  4. probleme de link avec visual studio .net 2003
    Par kamal101 dans le forum MFC
    Réponses: 9
    Dernier message: 28/03/2005, 21h44
  5. [dev-cpp] probleme de link
    Par alex1er dans le forum Dev-C++
    Réponses: 5
    Dernier message: 20/01/2005, 17h41

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