下面是我们几乎每个程序员学习C语言的第一个程序:
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
这么简单的一个程序,在Linux里面其实执行的具体过程如下:
[root@localhost hello]# rm -rf a.out [root@localhost hello]# gcc -E hello.c -o hello.i [root@localhost hello]# gcc -S hello.i -o hello.s [root@localhost hello]# as hello.s -o hello.o [root@localhost hello]# ld -static /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/gcc/i386-redhat-linux/4.1.1/crtbeginT.o -L/usr/lib/gcc/i386-redhat-linux/4.1.1 -L/usr/lib -L/lib hello.o --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/i386-redhat-linux/4.1.1/crtend.o /usr/lib/crtn.o [root@localhost hello]# ./a.out Hello World [root@localhost hello]#
具体的过程大致如下:
1:预编译;
2:编译;
3:汇编;
4:链接。
文章的脚注信息由WordPress的wp-posturl插件自动生成
微信扫一扫,打赏作者吧~![[整理][转载]win下网卡抓包发包库Npcap使用](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2023/08/demo_1-1024x711.jpg&w=280&h=210&zc=1)
![[转载]基础数据char,int,double,string是线程安全的吗?](http://www.jyguagua.com/wp-content/themes/begin/img/random/17.jpg)
![[整理]how to run flask with pyqt5](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/03/pyqt_flask.png&w=280&h=210&zc=1)
![[已解决]LINK : fatal error LNK1158: cannot run 'rc.exe' 错误的解决办法](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2021/02/Snipaste_2021-02-17_15-18-26-1024x505.png&w=280&h=210&zc=1)