gcc -o skriver byggutdata till en utdatafil.
gcc -O ställer in kompilatorns optimeringsnivå .
Skriv byggutdata till en utdatafil.
$ gcc [options] [source files] [object files] -o output file
minfil.c:
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run\n");
}
Bygg myfile.c på terminalen och kör utdatafilen myfile :
$ gcc myfile.c -o myfile
$ ./myfile
Program run
$
Ställ in kompilatorns optimeringsnivå.
alternativ | optimeringsnivå | utförandetid | kodstorlek | minnesanvändning | sammanställningstid |
---|---|---|---|---|---|
-O0 | optimering för kompileringstid (standard) | + | + | - | - |
-O1 eller -O | optimering för kodstorlek och exekveringstid | - | - | + | + |
-O2 | optimering mer för kodstorlek och exekveringstid | -- | + | ++ | |
-O3 | optimering mer för kodstorlek och exekveringstid | --- | + | +++ | |
-Os | optimering för kodstorlek | -- | ++ | ||
-Ofast | O3 med snabba ingen exakta matematiska beräkningar | --- | + | +++ |
+öka ++öka mer +++öka ännu mer -minska --minska mer ---minska ännu mer
$ gcc -Olevel [options] [source files] [object files] [-o output file]
minfil.c:
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run\n");
}
Bygg myfile.c på terminalen och kör utdatafilen myfile :
$ gcc -O myfile.c -o myfile
$ ./myfile
Program run
$