C++ 如何在ubuntu中更改g ++的默认输出文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3763086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 13:38:42  来源:igfitidea点击:

How to change default output file of g++ in ubuntu?

c++ubuntug++

提问by Nullpoet

Trivially

琐碎的

g++ sample.c

generates a.out

产生 a.out

Can g++ be configured to output to a different default name for output file ?

可以将 g++ 配置为输出到输出文件的不同默认名称吗?

回答by codaddict

You need to use the -ooption of g++

您需要使用以下-o选项g++

g++ -o output_file_name  source.cpp

回答by Brian R. Bondy

Use the g++-o switch: g++ sample.cc -o myoutfile

使用g++-o 开关:g++ sample.cc -o myoutfile

See a man page for g++

查看g++手册页

-o file
Place output in file file.

-o file
将输出放在文件文件中。

回答by Kendots

If you want to change the default output name to testfor example, all you need to do is go to .bashrc, and put in:

test例如,如果您想将默认输出名称更改为,您需要做的就是转到 .bashrc,然后输入:

alias g++='g++ -o test'

But you need to reopen a new terminal for it to work.

但是您需要重新打开一个新终端才能使其工作。

回答by pszilard

Man pages are your friends:
$ man g++(and just do a search for "out" and you're done ;)

手册页是您的朋友:(
$ man g++只需搜索“out”即可完成;)