Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

g++

ubuntu

Trivially

g++ sample.c 

generates a.out

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

like image 280
Nullpoet Avatar asked Sep 21 '10 17:09

Nullpoet


People also ask

Which G ++ option is used to name an output file?

specify output file name This option tells g++ to place its output in the file output-file. If -o is not specified, the default is to put the executable output in a file named in a. out and the object file for source.

What is difference between G ++ and GCC?

DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.

Can G ++ compile C code?

G++ is the name of the compiler. (Note: G++ also compiles C++ code, but since C is directly compatible with C++, so we can use it.).


1 Answers

You need to use the -o option of g++

g++ -o output_file_name  source.cpp 
like image 186
codaddict Avatar answered Sep 19 '22 15:09

codaddict