目录
一、Vim编辑hello.c
- 编辑hello.c
二、分别用下面指令编译并查看结果
gcc -E hello.c -o hello.i
gcc -S hello.i -o hello.s
gcc -c hello.s -o hello.o
gcc hello.o -o hello
1.gcc -E hello.c -o hello.i
2.gcc -S hello.i -o hello.s
3.gcc -c hello.s -o hello.o
4.gcc hello.o -o hello
三、查看运行结果
输入 ./hello
运行结果如下
四、使用gdb调试函数调用
- 静态编译 hello.c
输入gcc -g -static hello.c
- 使用gdb调试
输入gdb a.out
- 使用 list查看代码
- 使用break设置断点
分别在第6行、第10行设置两个断点
- 输入 r 运行程序
-使用 print 打印变量
- 一直用next直到程序结束
五、gcc过程改为makefile管理
- 编辑makefile文件
输入vim makefile
,编写makefile文件如下
- 运行makefile文件
make makefile
运行结果如下
- 使用
make clean
清除刚才生成的文件