Title: ???? ??? - (5) GCC
1???? ???- (5) GCC
- Konkuk Univ.
- Dept. of Electronics
Konkuk Univ. Dept. of Electronics
2GCC
- GCC(GNU C Compiler)
- GCC(GNU Compiler Collection) C, C, Java,
Fortran, Ada, Objective-C/C - GCC? ??? ???? 1987? GNU ????? ????? ????. GNU
????? ????? ??? ??? ? ??? ?? ????? ??? ?????. - ?? ???? ????, ???? ????? ???? ??? ??? ? ?? ???
??? ?? ? ??? ?? - GCC 4.1 Alpha, ARM, Blackfin, H8/300,
System/370, System/390, IA-32 (x86) and AMD64,
IA-64 i.e. the "Itanium", Motorola 68000,
Motorola 88000, MIPS, PA-RISC, PDP-11, PowerPC,
SuperH, SPARC, VAX, Renesas R8C/M16C/M32C
families, MorphoSys family - gcc ? ????? ????? ?? ????? ???
Konkuk Univ. Dept. of Electronics
3C compile ??
.c .cc .C
.o
.s
???? (preprocessor)
???? (compiler)
???? (assembler)
?? (linker)
.s
.o
a.out
Konkuk Univ. Dept. of Electronics
4C compile ?? cont.
- C preprocessing (cpp) exgt define xx 100
- C compile (cc1) output) filename.s // assembly
code - Assemble (as) output) relocatable object file
- Link (ld) output) relocatable object file or
executable file
Konkuk Univ. Dept. of Electronics
5C compile ?? cont.
- ???(preprocessing)
- define, include, if? ?? ??? ??? ??
- ??? ??? ?? c ????? ??
- ???(compile)
- ?? ?? ?? ????? ?? ??? ???? ??? ??(.s)
- ????? ???? ??? ???? ?? ?? ????? ???
- ??? ???? ?? ??? ????? ?? ??? ???? ?? ??? ???
Konkuk Univ. Dept. of Electronics
6C compile ?? cont.
- ???(assemble)
- ???? ??? ?? ??? ???? ??? ??(.o)
- ???? ?? gas ????? ???
- ????? ???(CPUOS)?? ??? ?? ?? ???? ?? ??
- ??(linking)
- ???? ??? ??? ?? ??? ??(.o)
- ????? ??? ? ???? ???
- ??? ?? ld ????? ??
Konkuk Univ. Dept. of Electronics
7GCC file name
- gcc ? C compiler ? ? ??? assembler ? ??????? ??.
- gcc ? ??? ?? ???? ??? ? ??.
- .c preprocessingC compilerassemblelink
- .i C compiler assemblelink
- .s preprocessingassemblelink
- .S assemblelink
Konkuk Univ. Dept. of Electronics
8GCC ??
Konkuk Univ. Dept. of Electronics
9C preprocessing
Konkuk Univ. Dept. of Electronics
10Make
- make ??
- Makefile? ???? ???? ???? ??? ???(????)? ???? ???
?? ???? - ?? ??? ??? ??(??)? ???? ??? ???? ???? ?? ?? ??
- ????? ?? ??? ?? ?? ??
Konkuk Univ. Dept. of Electronics
11GCC options
- -o OPTION
- ??(output) ???? ??? ?????.
- gcc -o hello hello.c hello.c?? ??? hello?? ?????
?? - -E OPTION
- Preprocessing ??? compile
- -c OPTION
- ???(compile) ??? ?? ?? ??
- gcc -c hello.c hello.c ???? .c? ???? hello.o??
???? ??? ?? - -I OPTION
- include ???? ??? ?? ??? ???? ?? ??? ??
- gcc -c source.c Iinclude -I? ???
Konkuk Univ. Dept. of Electronics
12GCC options cont.
- g OPTION
- ???? ??????? ??? ??? ??
- gcc g o hello hello.c
- -O OPTION
- ??? ???(optimization)
- -O2? ?? ?? ???, -O -O1, -O0?? ?? ???? ?? ??,
??? -O1 - -l OPTION
- ?? ?????? ????? ??
- -L OPTION
- ? ?????? ?? ????? ??? ?? ?
Konkuk Univ. Dept. of Electronics
13make Makefile
- ?? ?? ??
- ???? ?? ?? ? ??? ???.
- ex) (CC) gcc
- Test label? ????? foo.o, main.o ??? ?? ????? ?
- foo.c, main.c? ??? ?? ??? ??
- make clean? ???? ???? label
Makefile
Konkuk Univ. Dept. of Electronics
14make Makefile cont.
main.c
execute make
foo.c
Konkuk Univ. Dept. of Electronics