<-Back to home
<-Page à Aurélie
<- Computer cheat sheet
<- Fiche Info

La Base- Compiler un code en C / The Basic Basis- Compiling C code!

En ligne de commande / command line : gcc -o exefile file.c -lm
Makefile:

CC = mpicc // Compilateur - Compiler name
CFLAGS = -FLAG1 -FLAG2 -... // Signaux de compilation - Compiling flags
LIBS = -lm -somelib ... // Libraries


all:
myexe1 myexe2 mylib.a ...
exe1:
exe1.o file1.o file2.o ...
$(CC) $(CFLAGS) exe1.o file1.o file2.o -o exe1 $(LIBS)
exe2:
exe2.o myfile1.o myfile2.o ...
$(CC) $(CFLAGS) exe2.o myfile1.o myfile2.o -o exe2 $(LIBS)
mylib.a:
mylib.o
ar crv mylib.a mylib.o
mylib.o:
mylib.c
clean:
rm -f *.o mylib.a exe1 exe2 ...

Pour compiler avec des options: make option=1 exefile

Trucs / Tips:
Si la commande "exefile" ne marche pas, toujours essayer ./exefile If "exefile" command won't work, always try ./exefile
Erreur de compilation: "Pas d'espace disponible sur le périphérique"
Solution: rm -f core !
Janvier 2003