Linux mint установка gcc

How To Install GCC on Linux Mint 20

In this tutorial, we will show you how to install GCC on Linux Mint 20. For those of you who didn’t know, The GNU Compiler Collection (GCC) is a compiler system produced by the GNU project to support various programming languages. The current version is GCC 9.3, released on March 12, 2020, supporting several major programming languages: C, C++, Objective-C, Objective-C++, Fortran, Ada, D, Go, and BRIG (HSAIL).

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you through the step-by-step installation of the GNU Compiler Collection (GCC) on a Linux Mint 20 (Ulyana).

Prerequisites

  • A server running one of the following operating systems: Linux Mint 20.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.

Install GCC on Linux Mint 20 Ulyana

Step 1. Before running the tutorial below, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

Step 2. Installing GCC on Linux Mint 20.

Now we run the following command to install GCC Compiler:

sudo apt install build-essential

Sometimes it’s wise to have a manual page too. Install the manual pages with the following command:

sudo apt install manpages-dev

Verify the GCC compiler installation with the command:

You will see something like below:

gcc (Ubuntu 9.3.5-10ubuntu2) 9.3.5 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Congratulations! You have successfully installed GCC. Thanks for using this tutorial for installing the latest version of GCC Compiler on the Linux Mint system. For additional help or useful information, we recommend you check the official GCC website.

Читайте также:  Операционная система linux антивирус

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Источник

Compile C Program in Linux Using GCC

The full form of GCC is GNU Compiler Collection. GCC has compilers for C, C++, Objective-C, Ada, Go, Fortran and many more programming languages. These are all open source and free to use.

In this article, I will show you how to install GCC and compile C programs in Linux using GCC. I will use Debian 9 Stretch for the demonstration. But I will show you how to install GCC on wide variety of Linux distributions. Let’s get started.

Installing GCC on Ubuntu and Debian GNU/Linux:

On Ubuntu and Debian GNU/Linux distributions, GCC is really easy to install as all the required packages are available in the official package repository of Ubuntu and Debian. There is a meta package called build-essential, which installs everything you need in order to compile C and C++ programs on Ubuntu and Debian GNU/Linux distribution.

First, update the APT package repository cache with the following command:

The APT package repository cache should be updated.

Now install build-essential with the following command:

Now press y and then press to continue.

Now you can check whether GCC is working with the following command:

Installing GCC on Linux Mint:

You can install GCC on Linux Mint the same way as in Ubuntu/Debian as shown in the earlier section of this article.

Installing GCC on CentOS 7 and Fedora:

On CentOS 7 and Fedora, GCC is easier to install as well. The required packages are available in the official package repository of CentOS 7 and Fedora. You can install the Development Tools group to install all the required packages to compile C and C++ programs on CentOS 7 and Fedora.

First, update the YUM database with the following command:

YUM database should be updated.

Now install Development Tools group packages with the following command:

Now press y and then press to continue.

If you see this message, just press y and then press .

Now you can check whether GCC is working with the following command:

Installing GCC on Arch Linux:

You can install GCC on Arch Linux too. All the required packages are available in the Arch package repository. Arch also has a meta package base-devel, which you can install to get all the required tools needed to compile C and C++ programs on Arch Linux.

Читайте также:  Astra linux восстановление ядра

First, update the Pacman database with the following command:

Pacman database should be updated. In my case, it was already up to date.

Now install base-devel package with the following command:

Now press to select all unless you want to install very specific set of packages.

You may see something like this. It’s nothing serious as far as I know. It’s just a package was renamed from pkg-config to pkgconf. So Pacman is asking you whether you want to use the new package and remove the old one. Just press y and then press .

Now press y and then press .

Now check whether GCC is working with the following command:

Writing Your First C Program:

Now let’s write a very simple C program, which we will compile in the next section of this article below using GCC C compiler.

First, create a project directory (I am going to call it hello) with the following command:

Now navigate to the newly created directory with the following command:

Now create a new C source file (I am going to call it main.c) here with the following command:

Now open the file with any text editor (such as vim, nano, gedit, kate etc) of your choice.

To open the file with nano, run the following command:

To open the file with vim, run the following command:

To open the file with Gedit, run the following command:

To open the file with Kate, run the following command:

I am going to use Gedit text editor in this article.

Now type in the following lines and save the file.

Here, line 1 includes the stdio.h header file. It has function definition for the printf() function I used on line 4.

Every C program must have a main() function. It is the function that will get called when you run a C program. If you don’t write a main() function, you can’t run the C program. So I wrote a main() function in line 3line 7.

Inside the main() function, I called printf() library function in line 4 to print some text to the screen.

Finally, in line 6, I returned 0 from the program. On Linux world, when a program returns 0, it means the program ran successfully. You can return any integer you like but there are some Linux specific rules on what return value means what.

In the next section, I will show you how to compile the C program with GCC and run it.

Compiling and Running C Programs with GCC:

The command to compile a C source file with GCC is:

NOTE: Here, SOURCE_FILES is a whitespace separated list of C source files. The compiled executable file will be saved as OUTPUT_BINARY in your current working directory.

Читайте также:  Линукс для удаленного доступа

In our case, the main.c source file doesn’t depend on other C source file, so we can compile it with the following command:

The source file main.c should be compiled and hello executable file should be created as you can see in the screenshot below.

Now, you can run the hello executable binary file as follows:

As you can see, the correct output is printed on the screen.

So that’s basically how you use GCC to compile C programs on Linux. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

Источник

Как установить GCC на Linux Mint 20

hosting.energy недорогой хостинг сайтов

hosting.energy недорогой хостинг сайтов

В этом руководстве мы покажем вам, как установить GCC на Linux Mint 20. Для тех из вас, кто не знал, GNU Compiler Collection (GCC) — это система компиляции, созданная проектом GNU для поддержки различных языков программирования. Текущая версия — GCC 9.3, выпущенная 12 марта 2020 года, поддерживает несколько основных языков программирования: C, C ++, Objective-C, Objective-C ++, Fortran, Ada, D, Go и BRIG (HSAIL).

В этой статье предполагается, что у вас есть хотя бы базовые знания Linux, вы знаете, как использовать оболочку, и, что наиболее важно, вы размещаете свой сайт на собственном VPS. Установка довольно проста и предполагает, что вы работаете с учетной записью root, в противном случае вам может потребоваться добавить ‘ sudo ‘ к командам для получения привилегий root. Я покажу вам пошаговую установку GNU Compiler Collection (GCC) на Linux Mint 20 (Ульяна).

Установить GCC на Linux Mint 20 Ulyana

Шаг 1. Перед запуском приведенного ниже руководства важно убедиться, что ваша система обновлена, выполнив следующие apt команды в терминале

Шаг 2. Установка GCC на Linux Mint 20.

Теперь мы запускаем следующую команду для установки компилятора GCC:

sudo apt install build-essential

Иногда бывает целесообразно также иметь справочную страницу. Установите справочные страницы с помощью следующей команды:

sudo apt install manpages-dev

Проверьте установку компилятора GCC с помощью команды:

Вы увидите что-то вроде того, что показано ниже:

gcc (Ubuntu 9.3.5-10ubuntu2) 9.3.5 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Поздравляю! Вы успешно установили GCC . Благодарим за использование этого руководства для установки последней версии компилятора GCC в системе Linux Mint. Для получения дополнительной помощи или полезной информации мы рекомендуем вам посетить официальный сайт GCC .

Источник

Оцените статью
Adblock
detector