首页 > 科技 > GCC

GCC

2005年8月30日 7点44分 发表评论 阅读评论

GCC is the compiler released by Slackware Linux.If we use no parameter after gcc command, a file named “a.out” which could be executed will be created.For example,
issue the following command:

# gcc test.c
# ls

We could find “a.out” created.Of course,we can identify the output file’s name by adding parameter “-o”,for example:

# gcc  -o test test.c

The output executing file is created with the name “test” instead of “a.out”. For optimizing the program,use the parameter “-O” or “-O2”.Gcc compiler always compile the code as soon as possible,and make the program compiling easily.It seems helpful,however,this program has been complied is not optimized.So,we add the parameter “-O” or “-O2”.
-O : optimize generally
-O2 : create the code which run faster and is litter.

The programmer usually debug the code during the development.The following optional parameter maybe useful:
-g : gcc create the debug information recognized by the GNU in order to optimize.
-pg : the extra code is added to the base codes by GCC.

When the program runs,a file named “gmon.out” will be created which is usually used to analyze the statue and rate when runing the codes,we could know the time of each partition running. Note,if the code contains only main funtion,the gmon.out could not be known by the gprof.(Error messages: gprof : gmon.out file is missing call-graph data). The gprof are useful when there are other funtions in the code.

# gcc -pr -o test test.c
# ./test
# gprof ./test gmon.out

gdb: The GNU Debugger.There are following commands in the gdb:
file: get the executing files which is going to be debugged.
kill: terminate the program is debugging.
list : list the code,but it seems RH9.0 does not support this option.
run : run the code.
make : do not quit gdb and create executing file again
shell : do not quit gdb and we could issue the shell commands.

Two useful commands:

# ps -auex
# tar -xjvf xxx.tbz
分类: 科技 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须在 登录 后才能发布评论.