C学习1.0 - GCC

概念

GCC,GNU Compiler,现在又成为GNU Compiler Collection(g++ for C++, gcc for C, gcj for java…)

GNU Toolchain
  1. GNU Compiler Collection (GCC): a compiler suite that supports many languages, such as C/C++ and Objective-C/C++.
  2. GNU Make: an automation tool for compiling and building applications.
  3. GNU Binutils: a suite of binary utility tools, including linker and assembler.
  4. GNU Debugger (GDB).
  5. GNU Autotools: A build system including Autoconf, Autoheader, Automake and Libtool.
  6. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值