gcc的输出(The output of gcc)

编程入门 行业动态 更新时间:2024-10-15 10:13:26
gcc的输出(The output of gcc)

我在我的ubuntu操作系统上运行gcc。 我在c中编写了一个小程序并尝试编译它。 它的输出是像在Windows上一样的a.out。 如何让它发布Linux可执行文件?

I have gcc running on my ubuntu operating system. I wrote a small program in c and tried compiling it. It's output was an a.out like it would do on windows. How can I make it put out a Linux executable?

最满意答案

a.out 可执行文件(假设您已经完成了完整的编译,而不仅仅是生成目标文件,但这是最可能的情况)。 要运行它,请使用(从shell):

./a.out

如果你想给它一个不同的名字,只需重命名,或者更好:

gcc -o actualname myprog.c

获取一个名为actualname的可执行文件,然后运行(当然):

./actualname

请参阅以下记录:

pax> cat testprog.c #include <stdio.h> int main (void) { printf("Hi.\n\n"); return 0; } pax> gcc testprog.c ; ./a.out Hi. pax> gcc -o xyzzy testprog.c ; ./xyzzy Hi.

a.out is the executable (assuming you've done full compilation rather than just generation of object files but that's the most likely case). To run it, use (from a shell):

./a.out

If you want to give it a different name, simply rename it, or better:

gcc -o actualname myprog.c

to get an executable called actualname which is then run (of course) with:

./actualname

See the following transcript:

pax> cat testprog.c #include <stdio.h> int main (void) { printf("Hi.\n\n"); return 0; } pax> gcc testprog.c ; ./a.out Hi. pax> gcc -o xyzzy testprog.c ; ./xyzzy Hi.

更多推荐

本文发布于:2023-08-06 00:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1440815.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:gcc   output

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!