{"id":15305,"date":"2023-04-01T06:27:44","date_gmt":"2023-04-01T06:27:44","guid":{"rendered":"https:\/\/education.telefony-taksi.ru\/?p=15305"},"modified":"2023-04-24T17:30:35","modified_gmt":"2023-04-24T17:30:35","slug":"set-up-linux-for-c-programming","status":"publish","type":"post","link":"https:\/\/education.telefony-taksi.ru\/set-up-linux-for-c-programming.html","title":{"rendered":"Set up linux for c++ programming"},"content":{"rendered":"

\"HelloWorld<\/p>\n

To be able to write under Linux with C++ applications one needs a compiler and an editor (or an IDE).<\/p>\n

On Debian and Linux distributions based on Debian, first run the following statement:<\/p>\n

$ sudo apt install build-essential<\/p>\n

Under openSUSE – as root – the following instruction is to be used:<\/p>\n

$ zypper install -t pattern devel_basis<\/p>\n

And under Fedora (33 to 36) the following instruction leads to the goal:<\/p>\n

$ sudo dnf -y groupinstall “Development Tools”<\/p>\n

This installs all the tools needed for programming. In particular, the GCC compiler (GNU Compiler Collection) is installed. By the way, you can check if it is present on the system with<\/p>\n

be checked. More information about the GCC compiler can be found on the homepage of the GCC project.<\/p>\n

With the installation of these packages you are ready to go. Because on Linux systems several editors are installed by default, which could be used for programming. So let’s start with an example.<\/p>\n

Hello, World!<\/h2>\n

Open an editor of your choice, for example the “Text Editor” available under Gnome and enter the following code:<\/p>\n

#include using namespace std; int main()<\/p>\n

Save the file under the name “hello.cpp” from.<\/p>\n

To compile C++ code, the GCC compiler is invoked with the g++ command. The complete statement looks like this:<\/p>\n

$ g++ -o hello hello.cpp<\/p>\n

The option -o causes that an executable file (here: “hello”) is created. The program can now be started with<\/p>\n

can be executed. As expected, this leads to the output “Hello, World!”.<\/p>\n

Other editors<\/h2>\n

Simple programs can be written with the “Text Editor”, but more comfortable is a professional editor. The choice is not exactly small under Linux; here is a selection:<\/p>\n