Linux下GCC编程四个过程(2)
2)编译阶段
(Compiling)
第二步进行的是编译阶段,在这个阶段中,Gcc首先要检查代码的规范性、是否有语法错误等,以确定代码的实际要做的工作,在检查无误后,Gcc把代码翻译成汇编语言。用户可以使用”-S”选项来进行查看,该选项只进行编译而不进行汇编,生成汇编代码。
选项 -S
用法:[root]# gcc –S hello.i –o hello.s
作用:将预处理输出文件hello.i汇编成hello.s文件。
[root@richard hello-gcc]# ls
hello.c hello.i hello.s
如下为hello.s汇编代码
[root@richard hello-gcc]# vi hello.s
.file "hello.c"
.section .rodata
.LC0:
.string "hello world!\r\n"
.text
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
subl $12, %esp
pushl $.LC0
call printf
addl $16, %esp
movl $0, %eax
leave
ret
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"
3)汇编阶段(Assembling)
汇编阶段是把编译阶段生成的”.s”文件转成二进制目标代码.
选项 -c
用法:[root]# gcc –c hello.s –o hello.o
作用:将汇编输出文件test.s编译输出test.o文件。
[root]# gcc -c hello.s -o hello.o
[root]# ls
hello.c hello.i hello.o hello.s
相关文档:
在linux下如何查看硬件信息?
最进想买笔记本,希望在linux下验机。
查看cpu信息可以使用
cat /proc/cpuinfo
查看显卡使用
lspci |grep VGA
我只知道上面两种方法,请问高手还有别的查看方式吗?包括看cpu、内存、显卡、硬盘、主板等信息。
能详细点最好,谢谢各位。
-------------------------------------------- ......
在Linux
中通过locale
来设置程序运行的不同语言环境,locale
由ANSI C
提供支持。locale
的命名规则为<
语言>_<
地区>.<
字符集编码>
,如zh_CN.UTF-8
,zh
代表中文,CN
代表大陆地区,UTF-8
表示字符集。在locale
环境中,有一组变量,代表国际化环境中的不同设置:
1. & ......
1) 工具说明
在SecureCRT这样的ssh登录软件里, 通过在Linux界面里输入rz/sz命令来上传/下载文件. 对于RHEL5, rz/sz默认没有安装所以需要手工安装.
sz: 将选定的文件发送(send)到本地机器;
rz:运行该命令会弹出一个文件选择窗口, 从本地选择文件上传到服务器(receive).
下载安装包lrzsz-0.12.20.tar. ......
参见:http://isis.poly.edu/kulesh/stuff/src/klist/
Introduction:
Linux kernel is mostly written in the C language. Unlike many other languages C does not have
a good collection of data structures built into it or supported by a collection of standard libraries.
Therefore, you're probably excited ......
在找GTK的开发文档,发现在 /usr/share/doc/libgtk2.0-doc/里有个 tutorial的目录,里边有个gtk-tutorial.devhelp的文件,于是试试有没有devhelp这个工具,原来真的有,而且已经安装过了!
于是用它来打开这个开发文档,非常好用。而且里边还有其他库的帮助文档呢! ......