加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 运行g时我需要使用-o吗?

发布时间:2020-12-16 09:39:18 所属栏目:百科 来源:网络整理
导读:我有一个非常小的c程序,由两个文件组成:main.cpp和something.cpp.我想在OS X终端中使用g编译我的程序.这是我尝试过的: g++ main.cpp something.cpp ./a.out 它是否正确?我遇到过使用-o标志的示例.我不确定这是否必要. 解决方法 -o选项不是必需的.如果未指
我有一个非常小的c程序,由两个文件组成:main.cpp和something.cpp.我想在OS X终端中使用g编译我的程序.这是我尝试过的:

> g++ main.cpp something.cpp
> ./a.out

它是否正确?我遇到过使用-o标志的示例.我不确定这是否必要.

解决方法

-o选项不是必需的.如果未指定,则默认行为是将可执行文件放在“a.out”中:

-o file
Place output in file file. This applies regardless to whatever sort of output is being produced,whether it be an executable
file,an object file,an assembler
file or preprocessed C code.

If -o is not specified,the default is to put an executable file in a.out,the object file for source.suffix in source.o,its
assembler file in source.s,a
precompiled header file in source.suffix.gch,and all preprocessed C source on standard output.

是的,这是正确的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读