This tutorial will help you install and get ready for C++ programming on Ubuntu 24.04 "Noble Numbat". We will use the tools GNU G++ as the compiler and Geany IDE as the text editor. Both are free software. Lastly, we also mentioned links to a good C++ tutorial with examples for you at the end of this article. Now, let's start learning!
(Geany showing program-01.cpp, compiling it with g++ at the bottom, and showing the execution result at bottom-right on Ubuntu 24.04 "Noble Numbat")
Subscribe to UbuntuBuzz Telegram Channel to get article updates.
This article is for C++. If you want C language instead, read here.
What is C language?
What is Geany?
Geany is a free software programmer text editor as well as Integrated Development Environment (IDE) that has ability to write codes in all programming languages. At the Ubuntu Buzz, we present Geany as the choice and replacement to proprietary software Sublime Text and Visual Studio because it is free/libre, small, fast, lightweight, detects many languages automatically, and extensible by plugins and last but not least we practiced it on our computer course for years and we know it works very well for students. In this context, Geany is capable to write codes in C++ programming language with convenience for the user to click Compile, Build and Execute automatically. Read See Also for the links.
What is GCC?
1. Install The Compiler
Open up your Terminal and type the following command line followed by Enter. On our system, it takes about 54MB download and 200MB disk space.
$ sudo apt-get install g++
schiex
2. Install The Text Editor
Still on your Terminal, do the next command below. On our system, it takes about 3MB download and 14MB disk space. Notice how small it is for these days when popular proprietary software editors such as VSCode and Jetbrain's Clion respectively become more than 90MB and even 1GB.
$ sudo apt-get install geany
schiex
3. Run Geany and Create Your First Code
Run Geany.
Click File -> New -> a new empty file "untitled" created.
Click File -> Save as.
Create a new folder "cpp-programming" in Documents.
Erase "untitled" and write the name "program-1.cpp".
Save.
Once saved as program-1.cpp, write the following code exactly letter by letter:
#include <iostream>
using namespace std;
int main(){
cout << "Hello, C Plus Plus World!\n" << endl;
return 0;
}
Save it so the red text turns black on the tab.
Go next.
4. Compile, Build and Execute
Click Compile.
Click Build.
Click Execute.
See the result. It should say "Hello, C Plus Plus World!" there. Observe it.
If you failed, there must be something wrong with your requirements and it is often because you didn't install the C++ compiler.
If you can do this step successfully, then you are ready to C++ programming on Ubuntu. Go next.
5. Repeat for Other Codes
Visit our recommended link below and try to start making new programs following the lessons one by one.
****
How To Learn C++ Language
We recommend you to learn CPP by practice and with a teacher who is capable to train you. For that purpose, like the previous article, we recommend Cprogramming.com once again because they have a very good collection of C++ lessons with examples you can practice with Geany. A standard curriculum of CPP basics includes more or less the following chapters:
1. Basic C++ features
2. Pointers, arrays and strings
3. File I/O, command line arguments and classes
4. Linked lists, binary trees and recursion
5. Inheritance and class design
6. Templates
7. Enums, preprocessors, formatted outputs and random numbers
(A screenshot of Alex Allain's Cprogramming.com on the beginning of C++ lesson)
Go to their tutorial (under See Also below) and start learning one by one. Some tips for you: Copy-paste every example to Geany then compile then see how it runs is good to start. Don't hesitate!
****
Related Articles
Alternatives to Visual Basic (Qt SDK, GNOME Builder, Netbeans, MonoDevelop etc.)
Collection of Various Programming Language Setups (BASIC, C, C++, Java, Pascal, GTK and Qt)
List of Popular Free Software Written in C++ (0 A.D., Audacity, Blender, Godot, Inkscape, etc.)
****
See Also
CProgramming.com C++ Lessons Tutorial
C++ Programming Language (Wikipedia)
What is Free Software - The Definition
GNU GCC - The C++ Language Compiler
Geany - The Integrated Development Environment
KDE Plasma Desktop- The Kubuntu GUI and Apps are Written in C++
Telegram Desktop - The Fast Messenger is Also Written in C++
This article is licensed under CC BY-SA 3.0.