gcc -o skriver build -outputtet til en outputfil.
gcc -O indstiller compilerens optimeringsniveau .
Skriv byggeoutputtet til en outputfil.
$ gcc [options] [source files] [object files] -o output file
minfil.c:
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run\n");
}
Byg myfile.c på terminal og kør outputfilen myfile :
$ gcc myfile.c -o myfile
$ ./myfile
Program run
$
Indstil compilerens optimeringsniveau.
mulighed | optimeringsniveau | udførelsestid | kodestørrelse | hukommelsesforbrug | kompileringstid |
---|---|---|---|---|---|
-O0 | optimering til kompileringstid (standard) | + | + | - | - |
-O1 eller -O | optimering for kodestørrelse og eksekveringstid | - | - | + | + |
-O2 | optimering mere for kodestørrelse og eksekveringstid | -- | + | ++ | |
-O3 | optimering mere for kodestørrelse og eksekveringstid | --- | + | +++ | |
-Os | optimering for kodestørrelse | -- | ++ | ||
-Ofast | O3 med hurtige ingen nøjagtige matematiske beregninger | --- | + | +++ |
+øge ++øge mere +++øge endnu mere -reducere --reducere mere ---reducere endnu mere
$ gcc -Olevel [options] [source files] [object files] [-o output file]
minfil.c:
// myfile.c
#include <stdio.h>
void main()
{
printf("Program run\n");
}
Byg myfile.c på terminal og kør outputfilen myfile :
$ gcc -O myfile.c -o myfile
$ ./myfile
Program run
$