Compilation avec gcc
Pepper
-
allo-allo -
allo-allo -
Bonjour,
une petite question concernant l'utilisation de gcc (version 4.0.1); comme vous allez vous en rendre compte, je suis débutant dans le domaine :-)
Voilà, j'ai trois fichiers :
***** main.c *****
#include <stdio.h>
#include <stdlib.h>
#include "hello.h"
int main(void)
{
Hello();
return 0;
}
main.c est placé dans le répertoire suivant : /Users/Pepper/Desktop/test
***** hello.c *****
#include <stdio.h>
#include <stdlib.h>
void Hello(void)
{
printf("Hello World\n");
}
hello.c est placé dans le répertoire suivant : /Users/Pepper/Desktop/hello
***** hello.h *****
void Hello(void);
hello.h est placé dans le répertoire suivant : /Users/Pepper/Desktop/hello_header
Enfin voici mon makefile, placé dans /Users/Pepper/Desktop/test tout comme le fichier main.c :
hello: main.o hello.o
gcc -o hello main.o hello.o
main.o: main.c
gcc -o main.o -c main.c -I/Users/Pepper/Desktop/hello_header/
hello.o: hello.c
gcc -o hello.o -c hello.c
Avec ce makefile, on voit que j'ai pu me débrouiller pour indiquer l'endroit où se trouve le fichier hello.h. Le fichier main.o est d'ailleurs créé.
Par contre je n'ai pas trouvé comment faire pour indiquer l'emplacement de hello.c.
Du coup, en lançant la commande make dans le terminal, je trouve le message d'erreur suivant :
make: *** No rule to make target `hello.c', needed by `hello.o'. Stop.
Alors comment faire pour indiquer l'emplacement de hello.c ??
Merci d'avance !
une petite question concernant l'utilisation de gcc (version 4.0.1); comme vous allez vous en rendre compte, je suis débutant dans le domaine :-)
Voilà, j'ai trois fichiers :
***** main.c *****
#include <stdio.h>
#include <stdlib.h>
#include "hello.h"
int main(void)
{
Hello();
return 0;
}
main.c est placé dans le répertoire suivant : /Users/Pepper/Desktop/test
***** hello.c *****
#include <stdio.h>
#include <stdlib.h>
void Hello(void)
{
printf("Hello World\n");
}
hello.c est placé dans le répertoire suivant : /Users/Pepper/Desktop/hello
***** hello.h *****
void Hello(void);
hello.h est placé dans le répertoire suivant : /Users/Pepper/Desktop/hello_header
Enfin voici mon makefile, placé dans /Users/Pepper/Desktop/test tout comme le fichier main.c :
hello: main.o hello.o
gcc -o hello main.o hello.o
main.o: main.c
gcc -o main.o -c main.c -I/Users/Pepper/Desktop/hello_header/
hello.o: hello.c
gcc -o hello.o -c hello.c
Avec ce makefile, on voit que j'ai pu me débrouiller pour indiquer l'endroit où se trouve le fichier hello.h. Le fichier main.o est d'ailleurs créé.
Par contre je n'ai pas trouvé comment faire pour indiquer l'emplacement de hello.c.
Du coup, en lançant la commande make dans le terminal, je trouve le message d'erreur suivant :
make: *** No rule to make target `hello.c', needed by `hello.o'. Stop.
Alors comment faire pour indiquer l'emplacement de hello.c ??
Merci d'avance !
A voir également:
- Compilation avec gcc
- Breach compilation c'est quoi - Guide
- Codeblocks avec compilateur - Télécharger - Langages
- Ubuntu probleme avec gcc - Forum Ubuntu
- Comment installer un compilateur gcc (linux) ✓ - Forum Linux / Unix
- Compilation error: expected unqualified-id before '{' token ✓ - Forum C++