1.vim编辑hello.c
首先我们打开终端,输入以下代码。
vi hello.c
编辑hello.c
创建sub1.c
vi sub1.c
float x2x(int a,int b)
{float s=0;
s=a/b;
return s;
}
2分别查看用下面指令编译的结果
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
产生的文件我们可以用指令 file xxxx.xxx 进行查看
3.查看运行成果
这里为了区别后面的makefile就把运行结果放在了hh里面,我们输入代码。
gcc -o hh hello.c
可以看出我们的结果很对。
4.使用gdb调试
先编译成可执行文件,并启动gdb
gcc -g hello.c -o hello
然后进行一系列操作
5.gcc过程改为makefile
首先创建makefile文件:
touch makefile
用vim编辑:
vim makefile
编辑makefile文件:
用make也能得到编译结果:
通过这次操作学习,确实学到了很多东西,还是有很多不完美的东西,继续加油吧。