Bonjour,
j'ai trouvé un programme divisé en plusieurs parties sur internet : main.c, tableaux.c, tableaux.h
Je cherche à le compiler mais je n'y arrive pas, j'ai réalisé un Makefile pour que sa soit plus facile à compiler, mais sans succès
main.c
tableaux.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 #include <stdio.h> #include <stdlib.h> #include "tableaux.h" int main(){ long newTab[4]={0}; printf("la somme est %ld",sommeTableau(newTab,4)); return 0; }
tableaux.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 #include <stdio.h> #include <stdlib.h> #include "tableaux.h" long sommeTableau(long tableau[],long tailleTableau){ long somme =0; long i = 0; for (i=0;i<tailleTableau;i++){ somme=somme + tableau[i]; } return (somme); }
Makefile
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 #ifndef TABLEAUX_H #define TABLEAUX_H long sommeTableau(long tableau[],long tailleTableau); #endif // TABLEAUX_H
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 all: executable main.o: main.c gcc main.c tableaux.o: tableaux.c tableaux.h gcc tableaux.c executable: tableaux.o main.o gcc -o $@ tableaux.o main.o
message erreur : undefined reference to `main'
je ne sais pas quoi faire, je suis bloqué au niveau du Makefile
Partager