Bonjour voilà je voulais faire un simple exercice pour utiliser un makefile.
J'ai trois fichiers hello.c hello.h et main.c.
"hello.h"
"hello.c"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 #include <stdio.h> #include <stdlib.h> void hello(void);
"main.c"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 #include "hello.h" void hello(void) { printf("Hello"); }
"Makefile"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 #include "hello.h" int main(void) { hello(); return 0; }
Voici les erreurs lorsque je tape la commande "make":
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 all: main main:hello.o main.o gcc -o hello.o main.o hello.o:hello.c hello.h gcc -c hello.c main.o:main.c hello.h gcc -c main.c clean: rm -rf *.o mrproper:clean rm -rf main
Si vous pouviez m'aider.Merci !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 gcc -c hello.c gcc -o hello.o main.o main.o: In function `main': main.c:(.text+0x12): undefined reference to `hello' collect2: ld a retourné 1 code d'état d'exécution make: *** [main] Erreur 1
Partager