Basic Compilation of a C++ Program
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.


September 25, 2008 - 12:19 pm
Way cool – it worked great – i love the simplicity of the code.