This tutorial guides you to setup a C++ compiler and a text editor to start C++ programming on Ubuntu. The compiler is GNU g++ and the editor is Geany. With this tutorial, you can easily type C++ source codes from your lecturers or books, then compile and run them by clicks. This tutorial is intended for you beginners in programming especially if you're new Ubuntu users. Happy programming!

Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.

This tutorial is for C++ language. If you're looking for C language, read here.

1. Install Compiler

Do it:
sudo apt-get install g++

2. Install Editor

Do it:
sudo apt-get install geany

3. Write

Now type this source code and save it as code.cpp.

#include <iostream>
using namespace std;
int main()
cout << "hello, c plus plus!" << endl;
return 0;

4. Compile

Now press Compile button, and then press Build button. If your code has no error, then these should translate your source code into object code and then binary executable code. See gif animation below.

  • What's Compile button? This is the same as g++ -c code.cpp and it produces file named code.o. This is an object file.
  • What's Build button? This is the same as g++ -o code code.cpp and it produces file named code (without extension). This is an executable binary file
  • What's Run button? This is the same as ./code which is running the executable file produced from your source code.

5. Run

Now press Run button. This should run a Terminal and the code of yours says  hello, c plus plus!  on screen.

At this stage, you can compile C++ codes you find on internet. If you find errors, just learn it, find how to solve them. Learn from that.

Where to Get C++ Examples?

You will want many C++ source code examples to learn. Go to and the Tutorial Page to get sources and compile them one by one. Start from "Structure of a program" there.

, , , , ,