1c; " - o " # class="tags" href="/tags/OUTPUT.html" title=output>output_filename 不加 -o 默认 class="tags" href="/tags/GCC.html" title=gcc>gcc filename 生成 a.out eg: class="tags" href="/tags/GCC.html" title=gcc>gcc hello.c hello 生成: a.out class="tags" href="/tags/GCC.html" title=gcc>gcc -o hello.c hello 生成: hello
2 " - c " 只编译 不连接成为可执行文件 eg: class="tags" href="/tags/GCC.html" title=gcc>gcc -c hello.c 生成: hello.o
3. “ -g ” 加入调试信息 会增加函数包容量
4. “ -O” “-O2” optimise class="tags" href="/tags/YouHua.html" title=优化>优化程序c;缩短执行时间 执行时间查看: time ./filename eg:class="tags" href="/tags/YouHua.html" title=优化>优化optimize.c class="tags" href="/tags/GCC.html" title=gcc>gcc optimize.c -o optimize time ./optimize class="tags" href="/tags/GCC.html" title=gcc>gcc -O optimize.c -o optimize time ./optimize 发现时间变短了
5.“ -I ” 增加标准头文件查找目录 eg: class="tags" href="/tags/GCC.html" title=gcc>gcc -I/home hello.c -o hello 增加 home 目录
6. “ - l ” 增加自定义库 如增加: libldap库 名字去掉前缀lib eg: class="tags" href="/tags/GCC.html" title=gcc>gcc -llap hello.c -o hello
7.-static 静态链接库 和动态连接区别: 静态连接 把头文件复制到程序中 增加程序容量c; 动态链接 可供多个程序共享 eg: class="tags" href="/tags/GCC.html" title=gcc>gcc -static hello.c -o hello 生成文件大小明显增加
8. -Wll -wll -Wll 产生warning -wll 不产生warning
9. -D 宏定义 eg: 定义 ABC class="tags" href="/tags/GCC.html" title=gcc>gcc -DABC hello.c -o hello 同在程序中加入 #define ABC