目录
gcc常用命令
参考链接:Linux C编程基础 娄嘉鹏
GCC编译器(Linux gcc命令)30分钟入门教程
一、命令格式
gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-Wpedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] [@file] infile...
二、常用选项
-E |
仅执行预编译 |
gcc -E hello.c -o hello.i |
-S |
将C代码转换为汇编 |
gcc -S hello.i -o hello.s |
-c |
仅执行编译操作,不进行链接操作 |
gcc -c hello.s -o hello.o |
-o |
指定生成的输出文件。If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output. |
|
-I(大写的i) |
指定头文件目录 |
gcc main.c -I ../include -o main |
-L |
指定库文件所在的目录 |
gcc ../src/main.c -I ../include/head.h -L ../libs/ -l math |
-l |
指定程序要链接的库 |
gcc会在静态库名前加上前缀lib,然后追加扩展名.a得到的静态库文件名来查找静态库文件;动态库追加扩展名.so |
三、创建库
来源:https://www./content-4-462601.html
|