Linux Mint

How to Install GCC compiler on Linux Mint 20

The GNU compiler collection, which is the abbreviation for GCC, contains multiple compilers for various languages like C, C++, Go, etc. Using GCC, you can easily compile your programs on Linux Mint. Many open-source projects, including Linux Kernel, are compiled using the GCC compiler.

The build-essential package contains the GCC compiler, debugger, and many additional development tools. By installing the build-essential package, we can use GCC compiler on Linux Mint.

Installing GCC compiler on Linux Mint 20

The build-essential package is included in the Linux Mint base repository. open the terminal and update the apt package listing by typing:

$ sudo apt update

Now, install the build-essential package with the command:

$ sudo apt install build-essential

To continue installing the build-essential package, type ‘y’ on the command line.

Once the build-essentials package is installed, verify the GCC compiler installation with the command:

$ gcc --version

Getting started with GCC compiler on Linux Mint

Let’s compile our first C++ program with GCC compiler. Open your text editor and create a hello.cpp file:

#include

int main() {

    printf("Hello from LinuxHint \n");

    return 0;

}

To compile this C++ program with GCC compiler, write on your terminal

$ gcc <file-name>

$ gcc hello.cpp

My “hello.cpp” file is compiled successfully, and a new executable file, “a.out,” is created.

Let’s execute the ‘a.out’ file:

$ ./a.out

You can see that the message is printed on the terminal.

Conclusion

GCC compiler is used to compile the programming files on Linux. This post describes the installation of the GCC compiler on Linux Mint 20.

About the author

Kamran Sattar Awaisi

I am a software engineer and a research scholar. I like to write article and make tutorial on various IT topics including Python, Cloud Computing, Fog Computing and Deep Learning. I love to use Linux based operating systems.