{"id":18530,"date":"2022-09-17T05:21:29","date_gmt":"2022-09-17T05:21:29","guid":{"rendered":"https:\/\/linuxways.net\/?p=18530"},"modified":"2022-09-20T13:05:32","modified_gmt":"2022-09-20T13:05:32","slug":"install-gcc-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/install-gcc-ubuntu-22-04\/","title":{"rendered":"How to Install GCC in Ubuntu 22.04"},"content":{"rendered":"<p>Linux is a community-developed open-source software that provides compilers for many programming languages. The GNU is a collection of compilers, also known as GCC, which is a system compiler that is created to support the various scripting languages. It serves as the default compiler for the majority of GNU and Linux-related projects as well as the Linux kernel. The programming languages like C, C++, D, Fortran, Go and Ada need the GCC compiler for the execution of the code. The GCC is an open-source software that was created by the organization\u00a0known as the Free Software Foundation (FSF).<\/p>\n<p>The build-essential package is necessary for the GCC compiler. They contain the GNU debugger, the G++\/GNU compiler collection, as well as the other tools and libraries that are required for the compilation of the program. We will describe how to install and utilize the GCC compiler on the Ubuntu server in the remaining section of the article. All commands inside the terminal used in this manual are run in an Ubuntu 22.04 system.<\/p>\n<h2><strong>How to Install GCC in Ubuntu 22.04<\/strong><\/h2>\n<p>We provided the step-by-step guidelines for the installation of GCC compiler on the most recent version of Ubuntu which is the Ubuntu 22.04. Let\u2019s follow each step to install the GCC successfully.<\/p>\n<h3><strong>Step 1: Update and Upgrade the System<\/strong><\/h3>\n<p>Open the terminal of Ubuntu 22.04 by pressing the \u201cctrl+alt+t\u201d key. Enter the apt command to update and upgrade the system dependencies and packages. The apt command uses the prefix \u201csudo\u201d which enhances the privileges of the program. The sudo prefix allows the existing user to execute the specified command with the required permission as a super user in the Linux server. The \u201capt update\u201d command determines the latest packages and dependencies versions. Whereas the \u201capt upgrade\u201d upgrades the system packages to the most recent version by comparing the versions of each item in the list that we updated via \u201capt update\u201d. We used both commands simultaneously with the -y flag which is assumed as \u201cyes\u201d. When the apt command is executed, the password is required for the username. Then, we can see the dependencies and packages build with the done statement.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"165\" class=\"wp-image-18541\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-1.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-1.jpeg 700w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-1-300x71.jpeg 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/strong><\/p>\n<h3><strong>Step 2: Install the GCC Compiler<\/strong><\/h3>\n<p>Now, we have to install the GCC compiler with the build-essential meta-packages. The installation of the build-essential meta-packages is possible using the Ubuntu official repository. The default system repository for Ubuntu 22.04 contains these packages. The meta-packages of the required build tools are installed using the apt package manager. This build-essential package contains the GCC compiler, debugger, and other development libraries. The following command installs GCC in Ubuntu LTS 22.04:<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"217\" class=\"wp-image-18550\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-2.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-2.jpeg 722w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-2-300x90.jpeg 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/strong><\/p>\n<p>After building the GCC dependencies and additional packages, the prompt asks a permission to continue the installation of GCC. Enter the keyword \u201cY\u201d for further installation. Entering \u201cN\u201d is assumed as \u201cNo\u201d and cancels the installation.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"61\" class=\"wp-image-18555\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-3.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-3.jpeg 709w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-3-300x26.jpeg 300w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/strong><\/p>\n<h3><strong>Step 3: Verify the Version of GCC Compiler <\/strong><\/h3>\n<p>Once the installation of the GCC compiler is completed, check the version of the GCC that is installed in Ubuntu 22.04. Use the \u201cgcc\u201d prefix with the \u201c&#8211;version\u201d command. The version of GCC is displayed in the Ubuntu 22.04 shell.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"100\" class=\"wp-image-18562\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-4.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-4.jpeg 710w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-4-300x42.jpeg 300w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/strong><\/p>\n<h3><strong>Step 4: Install the GCC Manual Page <\/strong><\/h3>\n<p>Since we installed the GCC compiler in our Ubuntu 22.04 system, we also checkwith the version command whether GCC is successfully installed or not. Note that we can also install the documentation page of GCC in our system for using its libraries and how it supports our system. We have to follow the following command to install the GCC documentation pages for any further help for development.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"149\" class=\"wp-image-18568\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-5.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-5.jpeg 700w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-5-300x64.jpeg 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/strong><\/p>\n<h3><strong>Step 5: Create a GCC Program <\/strong><\/h3>\n<p>All the steps for the installation of the GCC compiler are accomplished. Now, we implement the C program to check the working of the GCC compiler. We create the file \u201cMyFile\u201d and assign the extension \u201c.c\u201d as it is a C program. Inside the \u201cMyFile.c\u201d, we use the C program library \u201cstdio.h\u201d with the prefix \u201c#include\u201d which is supported by the GCC compiler. This library is the header file for the default input and output of the C program.<\/p>\n<p>It includes the data relating to input and output functions. Then, we define the int main function for the program to be executed. We call the printf function of the C scripting language that is used to print the statement placed inside it. We state the brackets of the printf function. Lastly, we use the \u201creturn 0\u201d in our code which indicates that the code is executed successfully and achieved its objective.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"138\" class=\"wp-image-18571\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-6.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-6.jpeg 620w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-6-300x67.jpeg 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/strong><\/p>\n<h3><strong>Step 6: Compilation of a GCC Program <\/strong><\/h3>\n<p>Now, it&#8217;s time to compile the previous C program with our GCC compiler. We launch the Ubuntu 22.04 terminal and use the GCC as a prefix. Then, we use the -o flag with the file and define the file name with the \u201cc\u201d extension. Before running the following command, we have to ensure that the file is located in the home directory. Otherwise, we need to specify the file path in the terminal.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"37\" class=\"wp-image-18576\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-7.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-7.jpeg 705w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-7-300x16.jpeg 300w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/strong><\/p>\n<p>Now, the \u201cMyFile.c\u201d is executable by running the previous command. We utilize the following command to execute the \u201cMyFile.c\u201d in the terminal.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"678\" height=\"21\" class=\"wp-image-18580\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-8.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-8.jpeg 678w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-8-300x9.jpeg 300w\" sizes=\"auto, (max-width: 678px) 100vw, 678px\" \/><\/strong><\/p>\n<p>We successfully printed the statement of the C program with the help of the GCC compiler. As the C program statement is displayed in the terminal of Ubuntu 22.04.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"672\" height=\"77\" class=\"wp-image-18585\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-9.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-9.jpeg 672w, https:\/\/linuxways.net\/wp-content\/uploads\/2022\/09\/word-image-18530-9-300x34.jpeg 300w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/strong><\/p>\n<h2><strong>Conclusion <\/strong><\/h2>\n<p>This guide gives a detailed instruction for the installation of the GCC compiler in the Ubuntu 22.04 system. For the installation of the GCC compiler, we utilized the build-essential on an Ubuntu 22.04 system which is covered in detail. We can use the aforementioned steps for the GCC compiler to be installed in our system. These commands are compatible with every Ubuntu version, but we used the Ubuntu 22.04 system. Then, we used the GCC version command to validate the successful installation of the compiler. In the end, we executed the C program with the GCC command.<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Detailed instruction for the installation of the GCC compiler in the Ubuntu 22.04 system by utilizing the build-essential and the GCC version command.<\/p>","protected":false},"author":105,"featured_media":18684,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-18530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/18530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=18530"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/18530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/18684"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=18530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=18530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=18530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}