GCC Linux [A Complete Overview]

GCC is one of the core components in the GNU tools developed by Richard Stallman. It has GPL (General Public Licence). That means it is completely open-source and many other operating systems use this tool to compile many programming languages as well. In this article, I will show you a complete overview of GCC in Linux.

gcc linux logo

What is GCC?

GCC (GNU Compiler Collection) is one of the core tools of the GNU project. It is a compiler developed to compile many programming languages like C, C++, etc. Now, along with the Linux kernel developed by Linus Torvalds, it has become an integral part of the GNU/Linux operating system.

Initially, this compiler was developed for C language only. But now, many different languages like C++, Ada, Go, Fortran, and Objective-C are supported by the GCC compiler.

GCC Components

There are many components inside the GCC. It is a portable tool, which means it can be run on many different systems including windows systems. MinGW, MinGW-W64, Cygwin, etc are some of the tools that can run GCC on Windows. In many instances, one of these tools is required to use a programming language in another operating system like windows.

Cygwin and Mingw

How Does GCC Compiler Work?

GCC compiler follows a process for compiling any program in Linux. There are 4 basic steps to compiling in GCC. Preprocessing, Compiling, Assembly, Linking.

Preprocessing is the first step of the compiling process. In this process, the header files are searched and copied to the source code file. It removes comments, expands macros, and includes files.

The Compiling process runs the code into the GCC module. In this step, the preprocessed files are converted into assembly language which is just an intermediate-level human readable language. The main purpose is to communicate with the hardware.

The Assembly process converts the assembly code into binary, machine language code. In this step, all the machine starts to understand the program’s instructions.

The Linking is the last step in the whole compiling step. In this step, all the source codes are merged and even the library functions are considered. There’s also dynamic linking where the codes are not copied but binary file names are put inside the code.

gcc process

How to Install GCC?

Installing GCC is very easy. You can use the command line in Linux to install the GCC compiler. Steps to install the GCC compiler in Linux are shown below.

Step 01: Update the System

First, update the whole system and its packages. To do that you can use the following commands.

sudo apt update

It will show a prompt where you need to enter the password of the administrator. After that, the system will automatically update all the packages available.

Output >

Then, all the packages are updated in the system and a summary is shown in the command line.

updating all package in linux

Step 02: Install the build-essential package

You need to install the build-essential package. This package includes the GCC compiler inside. After installing this package you will be able to run different languages with this compiler.

sudo apt install build-essential

Again the prompt may ask for the password. When you enter the password, the system will look for packages under the build-essential package, and then the command line will look like this.

Output >

After that, the prompt will again ask whether you want to install the packages.

installing build-package

You have to press Y or y to start installing the package. It will take some time to download and install all the packages. Then the command will exit.

Pressing yes or no

Step 03: Check for the GCC Version

After installing the whole build-essential package, you may want to check whether the GCC package has been installed. There are 2 different ways to find the version information and check the installation at the same time.

3.1 Using the –version Option

You can find the version of the GCC in the system. Type the following command to show the version of the GCC.

gcc --version

Output >

Now you can see, the version of the GCC is shown. That means GCC has been successfully installed in the Linux system.

showing version information of gcc linux

3.2  Using the -v Option

You can also use the -v option to see further information about the version and the packages under the GCC compiler. Type the command below.

gcc -v

Output >

Here you will find much more information about the GCC compiler.

showing further version information

Step 04: Check the Manual Page of the GCC Compiler

Now you can check the manual page of GCC with the man command.

man gcc

Output >

As you can see the man page of the GCC compiler is shown below. Here you will find a description, synopsis, and different options available for the GCC compiler.

gcc man page

Conclusion

The GCC compiler is one of the core tools for Linux. It was developed in order to run C language which is the building block of the whole Linux operating system. Even now, many people use this compiler in other operating systems like Windows to run C language smoothly and efficiently.

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Md. Rafsan Zani

Hello, I’m Md. Rafsan Zani. I have recently completed my Undergraduate from the Bangladesh University of Engineering and Technology (BUET). Currently, I’m pursuing higher studies abroad. I’m really interested in computer science and would like to learn a lot about the wonderful world of computers. Currently, I’m working as a Linux Content Developer Executive and find Linux really interesting. I certainly would like to learn more about Linux and implement them in my future studies. Read Full Bio

Leave a Comment