If you are using Mac OSX or Linux, go to the folder where your cpp file is located in the terminal. On windows, you will need to install g++.

Assuming your source file is called main.app, and you want your output file to be called “hellos” then type the following:

g++ -o hellos main.cpp

To run it:

./hellos

Note: It is possible to compile the program without specifying the output file name but it will default to “a.out”:

g++ main.cpp

Additional compiler options can be found here.



2 Responses to “Basic Compilation of a C++ Program”  

  1. Way cool – it worked great – i love the simplicity of the code.


  1. 1 Conway’s Game of Life in C++ « Lijamez’s Blog

Leave a Reply