简体   繁体   English

使用 gcc 编译 C 程序

[英]Compiling a C program with gcc

A simple question that I cannot seem to find.一个我似乎找不到的简单问题。 When I am compiling a program with gcc my professor tells me to have -g and -o when I am compiling it and I am not too sure why.当我使用 gcc 编译程序时,我的教授告诉我在编译时使用 -g 和 -o,但我不太清楚为什么。 I could not find it in the man pages of gcc with there being so much on there.我在 gcc 的手册页中找不到它,那里有这么多。

For example...例如...

gcc -g -o myprogram myprogram.c

-g means to include debugging information, which enables a debugger to know where a named object (variable) is in the memory or registers of the executing process and to know which instructions correspond to which lines of source code. -g表示包含调试信息,它使调试器能够知道命名的 object(变量)在 memory 或执行进程的寄存器中的位置,并知道哪些指令对应于源代码的哪些行。

-o myprogram says to put the output file in myprogram . -o myprogram表示将 output 文件放入myprogram (If you do not specify -o with a file name, GCC defaults to putting the output in a file named a.out .) (如果没有指定-o文件名,GCC 默认将 output 放在名为a.out的文件中。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM