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:
Now, install the build-essential package with the command:
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:
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:
int main() {
printf("Hello from LinuxHint \n");
return 0;
}
To compile this C++ program with GCC compiler, write on your terminal
$ 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:
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.