Problème de compilation séparée
Bonjour à tous.
je n'arrive pas à compiler mon projet avec un makefile
Le projet est décomposé comme ça :
widget.c
widget.h
label.c
label.h
top.c
top.h
test.c
Avec comme contrainte ceci :
top n'a pas de référence vers d'autre fichier.
widget fait référence à top
label fait référence à widget et à top
test fait référence à top et label
voici le makefile en question :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
all :: test
top.o : top.c top.h
gcc -c top.c top.h -Wall -Wextra -lSDL -lSDL_ttf
widget.o : widget.c widget.h top.o
gcc -c widget.c widget.h top.o -Wall -Wextra -lSDL -lSDL_ttf
label.o : label.c label.h widget.o
gcc -c label.c label.h widget.o top.o -Wall -Wextra -lSDL -lSDL_ttf
test : test.c top.o label.o
gcc -o test test.c top.o label.o -lSDL -lSDL_ttf
clean ::
rm -rf *.o
mrproper :: clean
rm -rf test |
Et voici l'erreur :
Citation:
make: entrant dans le répertoire « /home/vincent/Bureau/SDL_GTK »
gcc -c label.c label.h widget.o top.o -Wall -Wextra -lSDL -lSDL_ttf
Using Makefile from ~/Bureau/SDL_GTK
gcc: widget.o: linker input file unused because linking not done
gcc: top.o: linker input file unused because linking not done
gcc -o test test.c top.o label.o -lSDL -lSDL_ttf
label.o: In function `Label_new':
label.c:(.text+0x213): undefined reference to `Widget_get_width'
label.c:(.text+0x21d): undefined reference to `Widget_get_height'
collect2: ld returned 1 exit status
make: quittant le répertoire « /home/vincent/Bureau/SDL_GTK »
make: *** [test] Erreur 1
Je ne comprend pas cette ligne
gcc: top.o: linker input file unused because linking not done
top.o est construit en premier cela ne devrait pas posser de problème pour l'édition de lien ?
mais le plus embétant reste ceci :
label.c:(.text+0x213): undefined reference to `Widget_get_width'
label.c:(.text+0x21d): undefined reference to `Widget_get_height'
mon fichier label.h
Code:
1 2 3 4 5 6 7 8 9 10
|
#ifndef label_h
#define label_h
#include <SDL/SDL_ttf.h>
#include <SDL/SDL.h>
#include "top.h"
#include "widget.h"
[...] |
label.c contient #include "label.h"
merci d'avance pour vos réponses.