{"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":"
<\/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
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
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
On an Ubuntu Linux Visual Studio Code, Sublime Text, emacs and vim can be installed via the package management “Ubuntu Software”. Alternatively, the installation of emacs and vim can also be done via the terminal, for example<\/p>\n
$ sudo apt install emacs-gtk
\n$ sudo apt install vim<\/p>\n
If you want it even more professional, you can also use an IDE (Integrated Development Environment). Especially Eclipse should be widely used.<\/p>\n
This IDE can be installed via “Ubuntu Software. Search for “Eclipse” and then start the installation by clicking on “Install.<\/p>\n
Alternatively, you can find the installation package for Linux on the Eclipse website in the download area under “Eclipse IDE for C\/C++ Developers”. In addition, there is also an “Eclipse Installer” that you could use instead. This installer can be started with the command<\/p>\n
starts. You will then see the following view, where you have to select “Eclipse IDE for C\/C++ Developers.<\/p>\n
<\/p>\n
Whichever way you go, a Java Runtime is required in any case:<\/p>\n
$ sudo apt install default-jre<\/p>\n
When everything is installed, Eclipse can be started in the terminal. Change to the directory “eclipse” and start the program with<\/p>\n
First a workspace must be selected. As soon as this is done, a new C++ project is started by clicking on “Create a new C\/C++ project.<\/p>\n
KDE users may prefer to use the development environment kDevelop. It can be installed via the software management Discover. After starting this IDE a new project is started by clicking on “New project started”.<\/p>\n
<\/p>\n
A console application could then be started by selecting<\/p>\n
> Standard> terminal> CMake C++<\/p>\n
can be started. In the opening editor you will see a Hello Word code sample.<\/p>\n
<\/p>\n
Finally, I would also like to mention a commercial product. And that is the cross-platform IDE CLion from JetBrains. Especially developers who are used to other JetBrains products will quickly get used to CLion. Fortunately, there is the possibility to download a 30-day trial version.<\/p>\n
Ubuntu users also have the possibility to download CLion as a snap package. In the terminal this is done with the following statement:<\/p>\n
$ sudo snap install clion –classic<\/p>\n","protected":false},"excerpt":{"rendered":"
To be able to write under Linux with C++ applications one needs a compiler and an editor (or an IDE). […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[135],"tags":[],"yoast_head":"\n