Undefined reference to nbJob
Bonjour à tous,
Petit problème à la compilation de mon projet. Voici sans plus attendre la sortie du terminal :
Code:
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
| adrien@adrien-portable:~/Documents/Travail/recherche/StageFlowShop/C++$ make
test -d Executable/ || mkdir -p Executable/
g++ -o Executable/Projet Application.o Atelier.o BandB.o ListeNoeuds.o Noeud.o Distrib.o Ordo.o Console.o Array.o -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -lpthread
BandB.o: In function `BandB::Developpe()':
BandB.cpp:(.text+0x81): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0xa9): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0xf7): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x12b): undefined reference to `Console<char*>::Afficher(char*)'
BandB.cpp:(.text+0x136): undefined reference to `Console<int>::Afficher(int)'
BandB.cpp:(.text+0x142): undefined reference to `Console<char*>::Afficher(char*)'
BandB.o: In function `BandB::BandB(Ordo*)':
BandB.cpp:(.text+0x180): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x19e): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x1a3): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x1b6): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x1bb): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x211): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x225): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x256): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x265): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x2c4): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x2f3): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x304): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x311): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x326): undefined reference to `BandB::nbJob'
BandB.o: In function `BandB::BandB(Ordo*)':
BandB.cpp:(.text+0x360): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x37e): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x383): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x396): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x39b): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x3ee): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x405): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x436): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x445): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x45a): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x49b): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x4ca): undefined reference to `BandB::probleme'
BandB.cpp:(.text+0x4e5): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x4f2): undefined reference to `BandB::nbMach'
BandB.cpp:(.text+0x505): undefined reference to `BandB::nbJob'
BandB.cpp:(.text+0x51c): undefined reference to `BandB::nbMach'
BandB.o: In function `BandB::Developpe()':
BandB.cpp:(.text+0x154): undefined reference to `Console<int>::Afficher(int)'
Noeud.o: In function `Noeud::Evaluer()':
Noeud.cpp:(.text+0x4a): undefined reference to `BandB::probleme'
Noeud.cpp:(.text+0x81): undefined reference to `BandB::probleme'
Noeud.cpp:(.text+0xda): undefined reference to `BandB::probleme'
Noeud.cpp:(.text+0x11d): undefined reference to `BandB::probleme'
Noeud.o: In function `Noeud::Noeud(Noeud*, int)':
Noeud.cpp:(.text+0x1c0): undefined reference to `BandB::probleme'
Noeud.o:Noeud.cpp:(.text+0x1e3): more undefined references to `BandB::probleme' follow
Ordo.o: In function `Ordo::NEH()':
Ordo.cpp:(.text+0xd3d): undefined reference to `Array<double>::Sort(double*, int*)'
Ordo.cpp:(.text+0xd48): undefined reference to `Array<double>::Reverse(int*)'
Ordo.o: In function `Ordo::NEHameliore()':
Ordo.cpp:(.text+0xf52): undefined reference to `Array<double>::Sort(double*, int*)'
Ordo.cpp:(.text+0xf5d): undefined reference to `Array<double>::Reverse(int*)'
Ordo.o: In function `Ordo::Flowshop()':
Ordo.cpp:(.text+0x1084): undefined reference to `Console<double>::EnString(double)'
Ordo.cpp:(.text+0x10cd): undefined reference to `Console<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Afficher(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
Ordo.cpp:(.text+0x112c): undefined reference to `Console<double>::EnString(double)'
Ordo.cpp:(.text+0x1198): undefined reference to `Console<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Afficher(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [Executable/Projet] Erreur 1
adrien@adrien-portable:~/Documents/Travail/recherche/StageFlowShop/C++$
adrien@adrien-portable:~/Documents/Travail/recherche/StageFlowShop/C++$ |
Citation:
BandB.o: In function `BandB::Developpe()':
BandB.cpp:(.text+0x81): undefined reference to `BandB::nbJob'
Le compilateur ne reconnaît visiblement pas nbJob (entre autres), qui est défini dans BandB.h :
Code:
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
| #ifndef BandB_H
#define BandB_H
#include "Noeud.hpp"
#include "ListeNoeuds.hpp"
#include "../Ordo.hpp"
class BandB
{
private:
static int nbJob;
static int nbMach;
Noeud* racine;
Noeud* noeudFils;
public:
static Ordo* probleme;
ListeNoeuds* listeNoeuds;
Noeud* noeudOpt;
int nbDev, nbNoeud;
double zopt;
double** spij;
public:
BandB(Ordo* ordo);
void Developpe();
Noeud* NouveauNoeudCourant();
};
#endif |
Et voici le BandB.cpp :
Code:
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
| #include "BandB.h"
#include <cstdlib>
#include "../../Entrees-Sorties/Console.h"
#include "../Ordo.h"
BandB::BandB(Ordo* ordo)
{
// Initialisation de la recherche
nbDev = 0; nbNoeud = 0;
probleme = ordo;
nbJob = probleme->reference->GetNbJob();
nbMach = probleme->reference->GetNbMach();
zopt = probleme->Resultat;
racine = new Noeud(listeNoeuds);
noeudOpt = racine;
listeNoeuds = new ListeNoeuds(this);
spij = new double*[nbJob]; // Initialisation du tableau à 2 dimensions spij.
for (int a=0; a< nbMach+1 ; a++)
{
spij[a] = new double[nbMach];
}
// Calculs preliminaires pour l'evaluatioin des bornes
for (int i=0; i<nbJob; i++)
for (int j=0; j<nbMach; j++)
{
int jj;
spij[i][j]=0;
if (j<nbMach-1)
for (jj=j+1; jj<nbMach; jj++)
spij[i][j] += probleme->reference->Pij(i,jj);
}
}
void BandB::Developpe()
{
Noeud* noeudCourant = racine;
while (noeudCourant)
{
int i;
// Developpement du noeud courant
nbDev++;
for (i=0; i<nbJob - noeudCourant->niveau; i++)
{
noeudFils = new Noeud(noeudCourant, i);
nbNoeud++;
noeudFils->Evaluer();
if (noeudFils->borneInf < zopt)
{
if (noeudFils->niveau<nbJob)
listeNoeuds->PlacerEnTete(noeudFils);
else
{
noeudOpt = noeudFils;
zopt = noeudOpt->borneInf;
}
}
}
// Nouveau noeud à developper
noeudCourant = NouveauNoeudCourant();
}
Console<char*>::Afficher("Nb noeuds apparus: ");
Console<int>::Afficher(nbNoeud);
Console<char*>::Afficher("\nNb noeuds developpes:");
Console<int>::Afficher(nbDev);
}
Noeud* BandB::NouveauNoeudCourant()
{
Noeud* noeudCourant;
if (listeNoeuds->Length!=0)
{
// Extrait le premier element de la liste, à condition qu'il soit interessant
noeudCourant = listeNoeuds->Premier();
while ((noeudCourant)&&(noeudCourant->borneInf>zopt))
noeudCourant = listeNoeuds->Premier();
}
else noeudCourant = NULL;
return(noeudCourant);
} |
Si vous aviez des idées par rapport à ce message d'erreur...?