×

How To Setup C++ Programming Tools on Ubuntu 24.04

How To Setup C++ Programming Tools on Ubuntu 24.04


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”)

C++ (C Plus Plus) is a programming language
(not a hardware nor a software) that was born 1980’s and created by Danish computer scientist Prof. Bjarne Stroustrup as an extension, improvisation to the C programming language. When the original C was from America, C++ was from Europe. C++ is a language known for its Object Oriented Programming or OOP concept, mainly used in desktop applications as well as high-class video games. It adds new features to C such as classes and inheritances, among others, and thanks to its OOP, many universities choose C++ to teach their students programming in Computer Science and Informatics. Examples of things written in C++ are beautiful desktop applications such as KDE, the desktop of Kubuntu, and Telegram Desktop, the fast messenger with billions of user, and complex games such as 0 A.D. Ancient Warfare. Read See Also to see the links.

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.

 

GNU GCC (formerly GNU C Compiler and now GNU Compiler Collection)
is a free software compiler software. A compiler is a program required to translate
code written in a language to another language. In this context, we will
use GCC as a compiler for C language as well as C++. To be more specific, the C++ compiler part of the GCC is called g++. For Ubuntu users, GCC is
well-known because almost all GNU/Linux distros including Ubuntu are
compiled using it. Read See Also for the links.

 

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

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

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.

 

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. 

Visit our recommended link below and try to start making new programs following the lessons one by one. 

 

****

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!

 

 ****

 

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.)

 

****

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.



Source link