概念
GCC,GNU Compiler,现在又成为GNU Compiler Collection(g++ for C++, gcc for C, gcj for java…)
GNU Toolchain
- GNU Compiler Collection (GCC): a compiler suite that supports many languages, such as C/C++ and Objective-C/C++.
- GNU Make: an automation tool for compiling and building applications.
- GNU Binutils: a suite of binary utility tools, including linker and assembler.
- GNU Debugger (GDB).
- GNU Autotools: A build system including Autoconf, Autoheader, Automake and Libtool.
- GNU Bison: a parser generator (similar to lex and yacc).
使用GCC
$ gcc hello.c
$ chmod a+x a.out
$ ./a.out
$ ./hello
- 加 ./a.out, 在bash中当前目录不在path中,windows算所以不用加
params
- o输出指定名称
- Wall warnin的所有log
- g 用于GDB额外的symbolic debug 信息
compile link分离
- compile (compile source to object file)
- link (link other object file and system library t- execute execute file)
g++ -c -Wall -g Hello.cpp
g++ -g -o Hello.exe Hello.o
params -c 用于compile, 如果fil事.o结尾就自动link
compile and link多个文件
> g++ -o myprog.exe file1.cpp file2.cpp
> g++ -c file1.cpp
> g++ -c file2.cpp
> g++ -o myprog.exe file1.o file2.o
好处
多个文件,一个file change,只需re link,不用re compile