Problème de référence indéfinie
Bonjour,
J'ai un problème de référence sous Eclipse, j'ai le message suivant lorsque que je compile mon projet
Citation:
undefined reference to `Entreprise::liste_entreprises'
Cette erreur apparait même lorsque j'exclus toutes mes autres classes du build.
J'ai donc plus qu'un fichier Entreprise.h et Entreprise.cpp.
Le fichier Entreprise.h contient une map static privée :
Code:
1 2
|
static map<string, Entreprise*> liste_entreprises; |
Une des méthodes dans le fichier cpp fait référence à cet attribut de cette manière :
Code:
1 2 3
| Entreprise::~Entreprise() {
Entreprise::liste_entreprises.erase(this->siret); // <-- Erreur : undefined reference to `Entreprise::liste_entreprises'
} |
Bien évidemment tous les includes sont OK ;)
Je ne trouve pas de solutions, étant donné que lorsque je compile à la main ça fonctionne.
Voici la totalité du retour console :
Citation:
make all
Building target: banque
Invoking: GCC C++ Linker
g++ -o"banque" ./Entreprise.o
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
./Entreprise.o: In function `~Entreprise':
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:23: undefined reference to `Entreprise::liste_entreprises'
./Entreprise.o: In function `Entreprise::setSiret(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:49: undefined reference to `Entreprise::liste_entreprises'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:49: undefined reference to `Entreprise::liste_entreprises'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:50: undefined reference to `Entreprise::liste_entreprises'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:52: undefined reference to `Entreprise::addEntreprise(Entreprise*)'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:54: undefined reference to `CompteException::CompteException(int, int)'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:54: undefined reference to `CompteException::~CompteException()'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:54: undefined reference to `typeinfo for CompteException'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:56: undefined reference to `CompteException::~CompteException()'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:56: undefined reference to `typeinfo for CompteException'
./Entreprise.o: In function `Entreprise::setNom(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:64: undefined reference to `CompteException::CompteException(int, int)'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:64: undefined reference to `CompteException::~CompteException()'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:64: undefined reference to `typeinfo for CompteException'
./Entreprise.o: In function `Entreprise::printIdents()':
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:82: undefined reference to `Entreprise::liste_entreprises'
/home/Thibaut/workspace/banque/Debug/../Entreprise.cpp:84: undefined reference to `Entreprise::liste_entreprises'
./Entreprise.o:(.gcc_except_table+0xbc): undefined reference to `typeinfo for CompteException'
./Entreprise.o:(.gcc_except_table+0xd4): undefined reference to `typeinfo for CompteException'
./Entreprise.o: In function `CompteException':
/home/Thibaut/workspace/banque/Debug/../CompteException.h:24: undefined reference to `vtable for CompteException'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [banque] Erreur 1
Quelqu'un aurait-il une idée du problème ?
Merci d'avance pour votre aide.