GCC是在Linux 平台(Linux platform)上工作的开发人员最喜欢使用的工具之一。它集成了多种流行编程语言的编译器,如Java、C、C++、Fortran等。如果您是从Linux开始您的旅程,那么还有什么比Ubuntu更好的选择。Ubuntu是所有(Ubuntu)Linux 发行版(Linux distribution)中最著名的。众所周知,它易于学习,同时不会影响事物的功能。所以,如果你需要知道如何在你的Ubuntu 系统上安装(Ubuntu system)GCC,这篇文章是一个完美的起点。我们将在以下部分探讨如何在Ubuntu上下载和安装(Ubuntu)GCC 。但在此之前,让我们更多地了解GCC。
如何在 Ubuntu 上安装 GCC(How to Install GCC on Ubuntu)
GCC(GNU Compiler Collection)是一组工具,用于将各种编程语言的源代码(source code)编译成二进制文件、可执行文件或库。GCC是一个可以安装在Ubuntu上的命令行编译器。
- GCC 编译器(GCC compiler),以及生成应用程序所需的许多库和其他工具,作为build-essential 包含在默认的 Ubuntu 存储库中(is included in the default Ubuntu repository as build-essential)。
-
C, C++, Java, Objective-C, Go, Fortran, AdaGCC 支持(are supported by GCC)C、C++、Java、Objective-C、Go、Fortran、Ada和更多编程语言。
- 许多开源项目,包括GNU 实用程序和 Linux 内核,都需要 GCC 来构建它们的代码(GNU utilities and the Linux kernel, require GCC to build their code)。
本教程将向您展示如何在Ubuntu 18.04上设置(Ubuntu 18.04)GCC 编译器(GCC compiler)。我们将教您如何安装发行版的稳定版本以及最新版本的GCC。对于Ubuntu 16.04和任何基于 Ubuntu 的发行版,例如Kubuntu、Linux Mint和Elementary OS ,这些步骤都是相同的。
注意:(Note:)您必须以 root 或具有 sudo 权限的用户身份登录才能在您的Ubuntu 系统(Ubuntu system)上创建新的存储库并安装软件包。
方法一:通过Ubuntu终端(Method 1: Through Ubuntu Terminal)
要在Ubuntu上设置GCC,您需要下载并安装 build-essential 软件包。打开终端窗口(terminal window)下载 gcc ubuntu。按照给定的步骤通过终端(Terminal)在Ubuntu上安装(Ubuntu)GCC。
选项 1:安装特定的 GCC 版本(Option 1: Install a Particular GCC Version)
1. 同时按Ctrl + Alt + T keys桌面(Desktop)上启动终端窗口。
注意:(Note:)或者,转到应用程序菜单并(app menu and search)搜索Terminal。
2.打开终端窗口(terminal window)后,使用下面的安装命令在(install command)Ubuntu上安装 build-essential 软件包。
sudo apt install build-essential
注意:(Note:) Sudo命令(Sudo command)会提示您输入密码。用户可以使用此命令以 root 身份运行单个任务。
3. Ubuntu 会提示您输入密码(password)。输入您的用户密码(password)以继续。
4.提供密码后,终端提示符将收集build-essential包的所有依赖项。(build-essential)Ubuntu接下来会询问您是否要安装该软件包。要继续,请按Y键。当您按下Y键时,Ubuntu将开始在您的机器上安装GCC 。
5. 此过程不应超过几分钟。使用man gcc命令,您可以在程序完成后浏览GCC 文档。(GCC documentation)
选项 2:安装多个 GCC 版本(Option 2: Install Multiple GCC Versions)
虽然大多数Ubuntu用户会对 build-essential 软件包感到满意,因为它包含GCC 10,但它并不是唯一可用的GCC版本。对其他语言的支持、改进的性能和扩展的功能都包含在较新版本的GCC 编译器(GCC compiler)中。您可以选择在Ubuntu上安装各种版本的GCC。这是下载 gcc ubuntu 的方法。
1.首先(First),在Ubuntu桌面上(Ubuntu desktop),打开一个终端(terminal)窗口。
2. 打开后,使用以下(following)命令在Ubuntu 软件(Ubuntu software)存储库中搜索可用的GCC包:
apt 搜索 gcc(apt search gcc)
3.通过提示搜索(Search)您要在 Ubuntu 上安装的GCC 版本。( GCC version)GCC 7、GCC 8、9 和 10(GCC 7, GCC 8, 9, and 10 )将可供安装。
4.找到要在 Ubuntu PC 上安装的版本后,使用下面的apt install 说明(apt install instructions)安装 GCC 。gcc-7、gcc-8、gcc-9和gcc-10是 GCC 包。
5.在 Ubuntu 上安装 GCC版本 7 。(version 7)
sudo apt install gcc-7 g++-7
6.在 Ubuntu 上安装 GCC版本 8 。(version 8)
sudo apt install gcc-8 g++-8
7.在 Ubuntu 上安装 GCC版本 9 。(version 9)
sudo apt install gcc-9 g++-9
8. 虽然强烈建议安装 build-essential 软件包以使GCC 10在Ubuntu上运行,但这并不是唯一的选择。安装 gcc-10 和 g++-10 包也会安装GCC 10。
sudo apt install gcc-10 g++-10
另请阅读:(Also Read:) 2022 年20 个最佳轻量级Linux 发行版(Linux Distros)
方法 2:通过 Synaptic 包管理器(Method 2: Through Synaptic Package Manager)
如果您不想使用控制台在Ubuntu上安装(Ubuntu)GCC,您可以使用Synaptic 包管理器(Synaptic Package Manager)来代替在 ubuntu 中下载 GCC。
选项 1:安装特定的 GCC 版本(Option 1: Install a Particular GCC Version)
按照以下步骤通过Synaptic Package Manager安装(Synaptic Package Manager)GCC。
1. 首先,确保已安装Synaptic 。要获取Synaptic,请转到Ubuntu 软件程序并搜索(Ubuntu Software program and search)Synaptic ,(Synaptic)然后安装它。
2. 安装后,通过在应用程序菜单(app menu)中搜索来打开Synaptic 包管理器(Synaptic Package Manager)。
3. 然后,在屏幕的右上角,寻找搜索(search)按钮。
4. 要显示搜索结果,请选择Synaptic 搜索按钮(Synaptic search button)并输入build-essential,然后按Enter键。
5. 在 Synaptic 搜索结果中查找build-essential。
6. 识别后,右键单击它并选择指定安装(Designate for installation)选项以标记用于 Synaptic 安装的 build-essential 包。
7. 在 Synaptic 中,找到Apply按钮并单击它以开始在Ubuntu上(Ubuntu)安装 GCC(GCC installation)。
另请阅读:(Also Read:)如何在Windows 10上安装(Windows 10)Linux Bash Shell
选项 2:安装多个 GCC 版本 (Option 2: Install Multiple GCC Versions )
要安装Ubuntu中 build-essential 软件包提供的版本以外的GCC 版本(GCC version),请执行以下步骤。
1. 首先,打开Synaptic Package Manager。
2. 打开 Synaptic 后,单击搜索按钮(search button)。
3. 然后从下面的列表中选择一种产品(products),然后将其输入到搜索框中(search box)。
- GCC 7:gcc-7, g++-7
- GCC 8:gcc-8, g++-8
- GCC 9:gcc-9, g++-9
- GCC 10:gcc-10, g++-10
4. 要安装您在Synaptic中找到的(Synaptic)GCC 包(GCC package(s)),请右键单击它并选择Apply按钮。
5. 根据需要重复此过程,在 Ubuntu 上安装任意多个版本的GCC 。
常见问题 (FAQ)(Frequently Asked Questions (FAQs))
Q1。GCC 是否已经安装在您的 Ubuntu 上?(Q1. Is GCC already installed on your Ubuntu?)
答。(Ans. )在所有Ubuntu 桌面(Ubuntu desktop)变体上,默认安装GCC 包。(GCC package)
Q2。哪个命令用于安装 GCC?(Q2. Which command is used to install GCC?)
答。(Ans. )使用up2date(up2date)命令、yum命令或apt-get命令(apt-get)Install GNI C/C++ ( GCC ) 和所需的库,具体取决于您的Linux 发行版(Linux distro)。
Q3。Ubuntu的目的是什么?(Q3. What is the purpose of Ubuntu?)
答。(Ans. )Ubuntu拥有管理公司、学校、房屋或企业所需的一切。所有主要软件,如办公套件(office suite)、浏览器、电子邮件和媒体应用程序,都已预先安装,Ubuntu 软件中心(Ubuntu Software Centre)还有数百个额外的游戏和应用程序。
推荐的:(Recommended:)
- 如何在Windows 10上找到睡眠(Windows 10)按钮(Button)
- 如何在 Slack 中发送 GIF
- 如何保持Microsoft Teams 状态可用(Microsoft Teams Status Available)
- 如何以正确的格式发送(Proper Format)Skype 代码(Skype Code)
我们希望这篇文章将有助于了解如何安装 gcc Ubuntu(how to install gcc Ubuntu)。您可以在我们的网站上找到更多与技术相关的文章。如果您对本文有任何建议或反馈,可以在下面的评论部分(comment section)与我们联系。
How to Install GCC on Ubuntu
GCC is one of the favorite tools used by develоpers working on the Linux platform. It serves as an integration of several compilers for popular programming languаges such as Java, C, C++, Fоrtran, and many more. If yoυ are beginning your jоurney with Linux, what better option there is than Ubuntu. Ubuntu is the most famous of all Linux distributіon out there. It is known to be easy to learn while not compromising on the features front of things. So, if you are in need to know how to install GCC on your Ubuntu system, this article is the perfect place to stаrt. We will explore how to download and instаll GCС on Ubuntu in thе sections below. But before that let’s knоw more about GCC.
How to Install GCC on Ubuntu
GCC (GNU Compiler Collection) is a set of tools for compiling source code from various programming languages into binaries, executables, or libraries. GCC is a command-line compiler that may be installed on Ubuntu.
- The GCC compiler, as well as many libraries and other tools necessary for generating applications, is included in the default Ubuntu repository as build-essential.
-
C, C++, Java, Objective-C, Go, Fortran, Ada, and more programming languages are supported by GCC.
- Many open-source projects, including the GNU utilities and the Linux kernel, require GCC to build their code.
This tutorial will show you how to set up the GCC compiler on Ubuntu 18.04. We’ll teach you how to install the stable version of the distribution as well as the most recent version of GCC. The steps are the same for Ubuntu 16.04 and any Ubuntu-based distribution, such as Kubuntu, Linux Mint, and Elementary OS.
Note: You must be logged in as root or a user with sudo privileges to create new repositories and install packages on your Ubuntu system.
Method 1: Through Ubuntu Terminal
To set up GCC on Ubuntu, you’ll need to download and install the build-essential package. Open a terminal window to download gcc ubuntu. Follow the given steps to install GCC on Ubuntu through the Terminal.
Option 1: Install a Particular GCC Version
1. Press Ctrl + Alt + T keys together to launch a terminal window on the Desktop.
Note: Alternatively, go to the app menu and search for Terminal.
2. Use the install command below to install the build-essential package on Ubuntu once the terminal window is open.
sudo apt install build-essential
Note: The Sudo command prompts you for your password. Users can use this command to run a single task as root.
3. Ubuntu will prompt you for your password. Enter your user password to continue.
4. The terminal prompt will gather all dependencies for the build-essential package once you’ve supplied your password. Ubuntu will next ask you whether or not you wish to install the package. To proceed, press the Y key. When you hit the Y key, Ubuntu will begin installing GCC on your machine.
5. This procedure should take no more than a few minutes. With the man gcc command, you may browse the GCC documentation after the procedure is complete.
Option 2: Install Multiple GCC Versions
While most Ubuntu users will be satisfied with the build-essential package because it contains GCC 10, it is not the only version of GCC available. Support for additional languages, improved performance, and expanded functionality are all included in newer versions of the GCC compiler. You have the option of installing various versions of GCC on Ubuntu. Here’s how to download gcc ubuntu.
1. First, on the Ubuntu desktop, open a terminal window.
2. Once it’s open, use the following command to search the Ubuntu software repositories for available GCC packages:
apt search gcc
3. Search through the prompt for the GCC version you want to install on Ubuntu. GCC 7, GCC 8, 9, and 10 will be available for installation.
4. Install GCC using the apt install instructions below once you’ve found the version you want to install on your Ubuntu PC. gcc-7, gcc-8, gcc-9, and gcc-10 are GCC packages.
5. To install the GCC version 7 on Ubuntu.
sudo apt install gcc-7 g++-7
6. To install GCC version 8 on Ubuntu.
sudo apt install gcc-8 g++-8
7. To install the GCC version 9 on Ubuntu.
sudo apt install gcc-9 g++-9
8. While installing the build-essential package is strongly recommended for getting GCC 10 to operate on Ubuntu, it isn’t the only option to do it. Installing the gcc-10 and g++-10 packages will also install GCC 10.
sudo apt install gcc-10 g++-10
Also Read: 20 Best Lightweight Linux Distros of 2022
Method 2: Through Synaptic Package Manager
If you don’t want to use the console to install GCC on Ubuntu, you may use the Synaptic Package Manager instead to download GCC in ubuntu.
Option 1: Install a Particular GCC Version
Follow these steps to install GCC through Synaptic Package Manager.
1. To begin, make sure Synaptic is installed. To get Synaptic, go to the Ubuntu Software program and search for Synaptic, then install it.
2. Open the Synaptic Package Manager by searching for it in the app menu once it has been installed.
3. Then, in the top-right corner of the screen, look for the search button.
4. To display the search results, pick the Synaptic search button and input build-essential followed by the Enter key.
5. Look through Synaptic search results for build-essential.
6. Once you’ve identified it, right-click on it and choose the Designate for installation option to mark the build-essential package for Synaptic installation.
7. In Synaptic, locate the Apply button and click it to begin the GCC installation on Ubuntu.
Also Read: How To Install Linux Bash Shell On Windows 10
Option 2: Install Multiple GCC Versions
To install a GCC version other than the one supplied with the build-essential package in Ubuntu, perform the steps below.
1. First, open Synaptic Package Manager.
2. Once Synaptic is open, click on the search button.
3. Then select one of the products from the list below and enter it into the search box.
- GCC 7: gcc-7, g++-7
- GCC 8: gcc-8, g++-8
- GCC 9: gcc-9, g++-9
- GCC 10: gcc-10, g++-10
4. To install the GCC package(s) you’ve found in Synaptic, right-click on it and pick the Apply button.
5. Repeat this procedure as needed to install as many versions of GCC as you like on Ubuntu.
Frequently Asked Questions (FAQs)
Q1. Is GCC already installed on your Ubuntu?
Ans. On all Ubuntu desktop variants, the GCC package is installed by default.
Q2. Which command is used to install GCC?
Ans. Install GNI C/C++ (GCC) and needed libs using the up2date command, yum command, or apt-get command, depending on your Linux distro.
Q3. What is the purpose of Ubuntu?
Ans. Ubuntu has everything you’ll need to manage your company, school, house, or business. All of the main software, like an office suite, browsers, email, and media apps, are pre-installed, and the Ubuntu Software Centre has hundreds of additional games and applications.
Recommended:
We hope this article will prove to be helpful in finding out how to install gcc Ubuntu. You can find many more articles related to tech on our website. If you have any suggestions or feedback regarding this article, you can reach out to us in the comment section below.