gcc -o skriver bygge utgang til en utgang fil.
gcc -O angir kompilatorens optimaliseringsnivå .
Skriv byggeutgangen til en utdatafil.
$ gcc [options] [source files] [object files] -o output file
myfile.c:
// myfile.c
#include <stdio.h/
void main()
{
printf("Program run\n");
}
Bygg myfile.c på terminal og kjør utdatafilen myfile :
$ gcc myfile.c -o myfile
$ ./myfile
Program run
$
Sett kompilatorens optimaliseringsnivå.
| alternativ | optimaliseringsnivå | utførelsestid | kodestørrelse | minnebruk | kompilere tid |
|---|---|---|---|---|---|
| -O0 | optimalisering for kompileringstid (standard) | + | + | - | - |
| -O1 eller -O | optimalisering for kodestørrelse og utføringstid | - | - | + | + |
| -O2 | optimalisering mer for kodestørrelse og utføringstid | - | + | ++ | |
| -O3 | optimalisering mer for kodestørrelse og utføringstid | --- | + | +++ | |
| -Os | optimalisering for kodestørrelse | - | ++ | ||
| -Rask | O3 med raske ingen nøyaktige matematiske beregninger | --- | + | +++ |
+ øke ++ øke mer +++ øke enda mer -redusere - redusere mer --- redusere enda mer
$ gcc -Olevel [options] [source files] [object files] [-o output file]
myfile.c:
// myfile.c
#include <stdio.h/
void main()
{
printf("Program run\n");
}
Bygg myfile.c på terminal og kjør utdatafilen myfile :
$ gcc -O myfile.c -o myfile
$ ./myfile
Program run
$