Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

Sujet : multiple definition de fonctions ! [ Archives / Divers ] (bidules)

jeudi 4 avril 2002 à 20:59:35 | multiple definition de fonctions !

bidules

bonjour,
lorsque je compile j'ai plein d'erreur me disant qu'il ya des multiple definitions dans mes fichiers objets :

ds tou les fichier .h il y a au debut le #ifndef _FICHIER_H_
#define _FICHIER_H_
ET #endif a la fin
j'ai 3 classes : Matrice :
ds Matrice.h il y a #include"graphique.h"
ds MatriceFonct.cpp il y a #include"Matrice.h"

TabSucc :
ds .h il y a aussi graphique.h
ds cpp il y a TabSucc.h

Goriente :
ds.h il y a Matrice.h et TabSucc.h
ds cpp : Goriente.h

j'ai compiler les fichiers cpp avec g++ -c et il n'y a pas eu d'erreur
Par contre qd je compile le tout :
g++ -o monprog monprog.cpp MatriceFonct.o TabSuccFonct.o GorienteFonct.o

voila : le resulta
[root@jojo projetSD]# g++ -o projet23 projet23.cpp GorienteFonct.o MatriceFonct.o TabSuccFonct.o -lcurses
GorienteFonct.o: In function `LigneH(int, int, int)':
GorienteFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
GorienteFonct.o: In function `LigneV(int, int, int)':
GorienteFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
GorienteFonct.o: In function `ConstruireEcran(void)':
GorienteFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
GorienteFonct.o: In function `Retablissement(void)':
GorienteFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
MatriceFonct.o: In function `LigneH(int, int, int)':
MatriceFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
MatriceFonct.o: In function `LigneV(int, int, int)':
MatriceFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
MatriceFonct.o: In function `ConstruireEcran(void)':
MatriceFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
MatriceFonct.o: In function `Retablissement(void)':
MatriceFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
TabSuccFonct.o: In function `LigneH(int, int, int)':
TabSuccFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
TabSuccFonct.o: In function `LigneV(int, int, int)':
TabSuccFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
TabSuccFonct.o: In function `ConstruireEcran(void)':
TabSuccFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
TabSuccFonct.o: In function `Retablissement(void)':
TabSuccFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
collect2: ld returned 1 exit status

help me please.

jeudi 4 avril 2002 à 21:50:17 | Re : multiple definition de fonctions !

jpeg

Est ce qu'il n'y aurait pas (par hasard) l'implémentation des fonctions citées (LigneV,ConstruireEcran ...) dans ton fichier graphique.h ?
Si c'est le cas, l'implémentation est compilée dans chaque module '.o' (le fichier est inclus directement ou indirectement) et à l'édition des liens ça merde (comme le montrent tes messages d'erreurs) à cause de la redondance ...
Dans de telles conditions, il te faudrait séparer les définitions (dans un graphique.h) de l'implémentation (dans un graphique.cpp) et de générer le .o correspondant avant de faire l'édition des liens ...
Si ce n'est pas le cas, donne moi d'autres précisions ...




-------------------------------
Réponse au message :
-------------------------------

bonjour,
lorsque je compile j'ai plein d'erreur me disant qu'il ya des multiple definitions dans mes fichiers objets :

ds tou les fichier .h il y a au debut le #ifndef _FICHIER_H_
#define _FICHIER_H_
ET #endif a la fin
j'ai 3 classes : Matrice :
ds Matrice.h il y a #include"graphique.h"
ds MatriceFonct.cpp il y a #include"Matrice.h"

TabSucc :
ds .h il y a aussi graphique.h
ds cpp il y a TabSucc.h

Goriente :
ds.h il y a Matrice.h et TabSucc.h
ds cpp : Goriente.h

j'ai compiler les fichiers cpp avec g++ -c et il n'y a pas eu d'erreur
Par contre qd je compile le tout :
g++ -o monprog monprog.cpp MatriceFonct.o TabSuccFonct.o GorienteFonct.o

voila : le resulta
[root@jojo projetSD]# g++ -o projet23 projet23.cpp GorienteFonct.o MatriceFonct.o TabSuccFonct.o -lcurses
GorienteFonct.o: In function `LigneH(int, int, int)':
GorienteFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
GorienteFonct.o: In function `LigneV(int, int, int)':
GorienteFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
GorienteFonct.o: In function `ConstruireEcran(void)':
GorienteFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
GorienteFonct.o: In function `Retablissement(void)':
GorienteFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
MatriceFonct.o: In function `LigneH(int, int, int)':
MatriceFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
MatriceFonct.o: In function `LigneV(int, int, int)':
MatriceFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
MatriceFonct.o: In function `ConstruireEcran(void)':
MatriceFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
MatriceFonct.o: In function `Retablissement(void)':
MatriceFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
TabSuccFonct.o: In function `LigneH(int, int, int)':
TabSuccFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
TabSuccFonct.o: In function `LigneV(int, int, int)':
TabSuccFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
TabSuccFonct.o: In function `ConstruireEcran(void)':
TabSuccFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
TabSuccFonct.o: In function `Retablissement(void)':
TabSuccFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
collect2: ld returned 1 exit status

help me please.

jeudi 4 avril 2002 à 22:48:54 | Re : multiple definition de fonctions !

bidules


c tout a fais ca toutes les fonctions citée (ligneV...) se trouve dans graphique.h.
Donc d'apres ce que tu as dit il faudrais que je declare les fonctions ds graphique.h et les definissent ds graphique.cpp,est ce cela? Car si g bien compris lorsque je compile les cpp a chaque fois les fonctions contenus ds graphique.h sont implementer et donc lors de l'edition de liens le compilateur ne c pas quelle definition prendre.Oui si c bien cela je comprend ce qui se passe(je n'est pas beaucoup d'experience ds le domaine de la compilation alors j'essaye de comprendre un peu).
Merci de ton aide.


-------------------------------
Réponse au message :
-------------------------------

Est ce qu'il n'y aurait pas (par hasard) l'implémentation des fonctions citées (LigneV,ConstruireEcran ...) dans ton fichier graphique.h ?
Si c'est le cas, l'implémentation est compilée dans chaque module '.o' (le fichier est inclus directement ou indirectement) et à l'édition des liens ça merde (comme le montrent tes messages d'erreurs) à cause de la redondance ...
Dans de telles conditions, il te faudrait séparer les définitions (dans un graphique.h) de l'implémentation (dans un graphique.cpp) et de générer le .o correspondant avant de faire l'édition des liens ...
Si ce n'est pas le cas, donne moi d'autres précisions ...




-------------------------------
Réponse au message :
-------------------------------

bonjour,
lorsque je compile j'ai plein d'erreur me disant qu'il ya des multiple definitions dans mes fichiers objets :

ds tou les fichier .h il y a au debut le #ifndef _FICHIER_H_
#define _FICHIER_H_
ET #endif a la fin
j'ai 3 classes : Matrice :
ds Matrice.h il y a #include"graphique.h"
ds MatriceFonct.cpp il y a #include"Matrice.h"

TabSucc :
ds .h il y a aussi graphique.h
ds cpp il y a TabSucc.h

Goriente :
ds.h il y a Matrice.h et TabSucc.h
ds cpp : Goriente.h

j'ai compiler les fichiers cpp avec g++ -c et il n'y a pas eu d'erreur
Par contre qd je compile le tout :
g++ -o monprog monprog.cpp MatriceFonct.o TabSuccFonct.o GorienteFonct.o

voila : le resulta
[root@jojo projetSD]# g++ -o projet23 projet23.cpp GorienteFonct.o MatriceFonct.o TabSuccFonct.o -lcurses
GorienteFonct.o: In function `LigneH(int, int, int)':
GorienteFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
GorienteFonct.o: In function `LigneV(int, int, int)':
GorienteFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
GorienteFonct.o: In function `ConstruireEcran(void)':
GorienteFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
GorienteFonct.o: In function `Retablissement(void)':
GorienteFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
MatriceFonct.o: In function `LigneH(int, int, int)':
MatriceFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
MatriceFonct.o: In function `LigneV(int, int, int)':
MatriceFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
MatriceFonct.o: In function `ConstruireEcran(void)':
MatriceFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
MatriceFonct.o: In function `Retablissement(void)':
MatriceFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
TabSuccFonct.o: In function `LigneH(int, int, int)':
TabSuccFonct.o(.text+0x0): multiple definition of `LigneH(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x0): first defined here
TabSuccFonct.o: In function `LigneV(int, int, int)':
TabSuccFonct.o(.text+0x80): multiple definition of `LigneV(int, int, int)'
/tmp/ccjCzXM6.o(.text+0x80): first defined here
TabSuccFonct.o: In function `ConstruireEcran(void)':
TabSuccFonct.o(.text+0x104): multiple definition of `ConstruireEcran(void)'
/tmp/ccjCzXM6.o(.text+0x104): first defined here
TabSuccFonct.o: In function `Retablissement(void)':
TabSuccFonct.o(.text+0x114): multiple definition of `Retablissement(void)'
/tmp/ccjCzXM6.o(.text+0x114): first defined here
collect2: ld returned 1 exit status

help me please.



Cette discussion est classé dans : text, int, in, multiple, definition


Répondre à ce message

Sujets en rapport avec ce message

Cacher le curseur [ par BsEtZeOpLhD ] Salut.J'essay de cacher le curseur sous win Xp.J'ai fait le code suivant :#include int WINAPI WinMain(HINSTANCE hinstExe, HINSTANC gcc, prob de compilation [ par Metrox ] 'lut all, je tourne ss une debian (knoppix, pr etre precis), et j'essaie de compiler un truc tt bete, mais il me sort une erreur...que faire?!?CODE(es Menu.... [ par erasor ] slt voila g prit une source d'un menu et je voudrai mettre une image en background o lieu d'une couleur ,voila la zone specifie: int x=cvar.menu_x, y= ODBC Connect dialog: lacks text if api called from dll [ par mfritschi ] hi,i am writing an abstract data access framework. it enables us amongother things to access databases without being interested in theactual underlyin Plugins WinAMP dans Visual Basic (toutes catégories de plugins) via un ActiveX en C [ par PaTaTe ] Salut tout le monde ;)J'avais déjà posé la question mais sans réponse alors je recommence.Je cherche une (ou plusieurs) personne(s) étant prete à m'ai Prob de compilation gcc [ par Tidam ] Salut a tous voila j'ai un ptit probleme de compilation avec gcc voyez par vous meme -bash-2.05b$ gcc -o belga main.cpp /tmp/ccRnrb multiple definition et aucun endroit pour situer l'erreur [ par theidiot ] Bonjours, je compile présentement sur dev-cpp et j'ai un message d'erreur comme suit:multiple definition of 'std::basic_ostringstream, std::allocator 'multiple definition' de fichiers en-tête [ par GIRAFE ENRHUMEE ] J'écris, sur Dev C++ 4, un projet C++ comportant 2 fichiers .cpp et un fichier .h.  L'un de mes fichiers .cpp comporte #include, jusqu'à présent tout verrifier un multiple [ par feanor11 ] Bonjour ; Je souhaite vérifier si un int est un multiple d'un autre int. Existe-t-il une fonction ou une technique pour cela ? Merci ; ListBox et GetText [ par anonyme_man_in_this_world ] salut  !!comment recuperer le text selectionné dans une list box ?j'ai essayé ceci mais ça n'a pas marché  :char Text[256] ;  int sel = SendDlgItemMes


Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,546 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.