Установить gcc на линукс

Installing GCC

The latest version of this document is always available at https://gcc.gnu.org/install/. It refers to the current development sources, instructions for specific released versions are included with the sources.

This document describes the generic installation procedure for GCC as well as detailing some target specific installation instructions.

GCC includes several components that previously were separate distributions with their own installation instructions. This document supersedes all package-specific installation instructions.

Before starting the build/install procedure please check the host/target specific installation notes. We recommend you browse the entire generic installation instructions before you proceed.

Lists of successful builds for released versions of GCC are available at https://gcc.gnu.org/buildstat.html. These lists are updated as new information becomes available.

The installation procedure itself is broken into five steps.

Please note that GCC does not support ‘ make uninstall ’ and probably won’t do so in the near future as this would open a can of worms. Instead, we suggest that you install GCC into a directory of its own and simply remove that directory when you do not need that specific version of GCC any longer, and, if shared libraries are installed there as well, no more binaries exist that use them.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”.

(a) The FSF’s Front-Cover Text is:

(b) The FSF’s Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.

For questions related to the use of GCC, please consult these web pages and the GCC manuals. If that fails, the gcc-help@gcc.gnu.org mailing list might help. Comments on these web pages and the development of GCC are welcome on our developer list at gcc@gcc.gnu.org. All of our lists have public archives.

Copyright (C) Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

These pages are maintained by the GCC team. Last modified 2023-03-22.

Источник

How to install GCC on Ubuntu 20.04

GCC is regarded as an indispensable component in the all-inclusive compiler of GNU. It is an aggregation of depository pertinent to the language of programming. The languages inclusive in the GCC are C, Fortran, Go, C++, Objective C- and various other essential languages. The GCC is reckoned as a build-essential because it manifests various other operating tools for open sources. You can consider it as a chief process for the well-versed operating systems, including Linux. It is a compiler because it inhibits the libraries for the programing language, that ease the accessibility of those languages in commands. GCC compiler is also a credential for the Linux kernel along with some primary instruments of GNU. This guide follows a very elementary procedure in terms of programming to successfully install the GCC compiler on ubuntu 20.04. once you are done installing, you can palpably induce the system for the compilation of the programming languages.

Читайте также:  Аналог fiddler для linux

Prerequisites

Equivalent to the installation of other packages on ubuntu, GCC also postulates some prerequisites before installing it on ubuntu 20.04. Those requirements encompass the availability of enough space for some latest binary files. Also, it is an inherent requirement for any form of installation to log-in the system via root user or through the user entailing the sudo privileges.

Installation Procedure

It has become excessively quick to download the GCC compiler on ubuntu. The reason is justified by the fact that the Linux system’s depository also contains the packages for build-essentials. Through these packages, you can conveniently download the GCC compiler. Primarily you can find these packages in the repository through the meta-package. If you want to access the GCC compiler after a convenient installation, then you should opt for the development package. That will assist you in downloading all the build-essentials of GCC in your system in a single go.

Installation Steps

You can achieve the successful installation of GCC in your ubuntu by three major steps. These steps are so easy that even if you are a beginner, you can handily use the commands for an effective installation. The steps for the installation of the GCC compiler on your Ubuntu 20.04 are as follows:

  • System Package updating.
  • Installation of the development package.
  • Downloading of manual pages (optional).
  • Verification of GCC.

System Packages Updating

In this step, use the simple and fundamental sudo commands to update and upgrade your existing packages. By inputting these commands, you can update your system packages. the sudo commands for this purpose are:

Although the upgrade command of sudo is not mandatory, make sure to run the command for updating your system packages. It is a crucial step because, without updating, you can precisely access the level of your system packages.

Installation of Development Package

This is the second step for the installation. Some people just leave the process after this step, and it is quite alright. The steps after this one are just to ensure the installation, so professional programmers usually install the GCC package using the first two steps only. But for beginners, it is recommended to perform all the steps just to be sure that you have successfully installed the compilation of GCC.

Читайте также:  Редактирование pdf astra linux

Dwell upon the fact that this command of sudo assist in the installation of the development package that itself is a build-essential of GCC compiler. Apply the following command of sudo to install the development package.

After this command, you will see an output window that will tell you about the successful installation. The output will also reveal all the additional packages that you have downloaded along with your development package. You will also witness the packages suggested by the system for downloading along with the recommendation of a manual page to understand the GCC development on your Ubuntu 20.04 fully. The output window will also ask you to type Y (Yes) for the continuation of the installation. Just press Y and then press Enter, and you will successfully install the GCC.

Downloading of Manual Pages

This step is optional because it doesn’t play any functional role in the overall installation of GCC. But it can assist you in understanding the usance of GNU for effective development. Type the following command if you want to download the manual pages.

With this, you will get a hold of the manual pages constituting the instructions for development.

Verification of GCC.

Now, this is the last step. You can skip it if you are a professional or if you are sure that the compiler has been installed. To verify your recently installed GCC compiler on ubuntu input this command in your system terminal:

It is important to know that you can also use this command at the beginning of the process if you have existing GCC on your system. It will tell you the existing version of the GCC compiler then.

Conclusion

This guide is well-detailed so that even if you are a beginner in the field of programming, you can still install GCC with efficiency. If you notice the output window after every command keenly, then you’ll know what is going on, what are the supplements downloads, and what you need to do further for assurance of your installation package. Also, if you are a beginner, then ensure the implementation of the last two steps to be on the safe side.

About the author

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.

Источник

Как установить GCC (необходимое для сборки) на Ubuntu 20.04

Коллекция компиляторов GNU (GCC) — это набор компиляторов и библиотек для языков программирования C, C ++, Objective-C, Fortran, Ada, Go и D. Многие проекты с открытым исходным кодом, включая ядро Linux и инструменты GNU, скомпилированы с использованием GCC.

В этой статье объясняется, как установить GCC в Ubuntu 20.04.

Установка GCC в Ubuntu 20.04

Репозитории Ubuntu по умолчанию содержат метапакет с именем «build-essential», который включает коллекцию компиляторов GNU, отладчик GNU и другие библиотеки и инструменты разработки, необходимые для компиляции программного обеспечения.

Читайте также:  Linux очистить bash history

Чтобы установить пакеты средств разработки, выполните следующую команду от имени пользователя root или пользователя с правами sudo :

sudo apt updatesudo apt install build-essential

Команда устанавливает множество пакетов, включая gcc , g++ и make .

Вы также можете установить справочные страницы об использовании GNU / Linux для разработки:

sudo apt-get install manpages-dev

Убедитесь, что компилятор GCC успешно установлен, выполнив следующую команду, которая выводит версию GCC:

Репозитории Ubuntu 20.04 предоставляют GCC версии 9.3.0 :

gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0 Copyright (C) 2019 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. 

Вот и все. В вашей системе Ubuntu установлены инструменты и библиотеки GCC.

Компиляция примера Hello World

Скомпилировать базовую программу на C или C ++ с помощью GCC довольно просто. Откройте текстовый редактор и создайте следующий файл:

// hello.c #include int main()  printf("Hello, world!n"); return 0; > 

Сохраните файл и скомпилируйте его в исполняемый файл:

Это создает двоичный файл с именем hello в том же каталоге, где вы запускаете команду.

Запустите программу hello с помощью:

Программа должна напечатать:

Установка нескольких версий GCC

В этом разделе приведены инструкции по установке и использованию нескольких версий GCC в Ubuntu 20.04. Новые версии компилятора GCC включают новые функции и улучшения оптимизации.

На момент написания этой статьи репозитории Ubuntu по умолчанию включают несколько версий GCC, от 7.xx до 10.xx

В следующем примере мы установим последние три версии GCC и G ++.

Установите нужные версии GCC и G ++, набрав:

sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10

Приведенные ниже команды настраивают альтернативу для каждой версии и связывают с ней приоритет. Версия по умолчанию — это версия с наивысшим приоритетом, в нашем случае это gcc-10 .

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8

Позже, если вы захотите изменить версию по умолчанию, используйте команду update-alternatives :

sudo update-alternatives --config gcc
There are 3 choices for the alternative gcc (providing /usr/bin/gcc). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/gcc-10 100 auto mode 1 /usr/bin/gcc-10 100 manual mode 2 /usr/bin/gcc-8 80 manual mode 3 /usr/bin/gcc-9 90 manual mode Press to keep the current choice[*], or type selection number: 

Вам будет представлен список всех установленных версий GCC в вашей системе Ubuntu. Введите номер версии, которую вы хотите использовать по умолчанию, и нажмите Enter .

Команда создаст символические ссылки на определенные версии GCC и G ++.

Выводы

Мы показали вам, как установить GCC в Ubuntu 20.04. Теперь вы можете посетить официальную страницу документации GCC и узнать, как использовать GCC и G ++ для компиляции программ на C и C ++.

Если вы столкнулись с проблемой или хотите оставить отзыв, оставьте комментарий ниже.

Источник

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