Pages

HOW TO COMPILE AND RUN A C++ PROGRAM in UBUNTU
----------------------------------------------

1. Type in source code in gedit

2. Save as filename.cpp
   (note that once you save as .cpp gedit will begin to show 
   source code relevent colors whenever the file is opened in gedit)

3. Open terminal (command line) and cd (change directory) over to 
   the directory where you saved the file.

4. At the prompt type: "g++ filename.cpp".

5. You may see a load of warnings and recommendations, but if the 
   code has no errors then an executable will still be created.

6. Type "ls" on the command line to see the program titled "a.out" 
   in the current directory.

7. If it's there (and wasn't before) that is your compiled file.

8. type "./a.out" to run it!