gcc -o skriver byggeutdata til en utdatafil.
gcc -O setter kompilatorens optimaliseringsnivå .
Skriv byggeutdataene til 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å terminal og kjør utdatafilen myfile :
$ gcc myfile.c -o myfile
$ ./myfile
Program run
$
Angi kompilatorens optimaliseringsnivå.
alternativ | optimaliseringsnivå | utførelsestid | kodestørrelse | minnebruk | kompileringstid |
---|---|---|---|---|---|
-O0 | optimalisering for kompileringstid (standard) | + | + | - | - |
-O1 eller -O | optimalisering for kodestørrelse og utførelsestid | - | - | + | + |
-O2 | optimalisering mer for kodestørrelse og utførelsestid | -- | + | ++ | |
-O3 | optimalisering mer for kodestørrelse og utførelsestid | --- | + | +++ | |
-Os | optimalisering for kodestørrelse | -- | ++ | ||
-Ofast | 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]
minfil.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
$