In this article, we will show you how to install the GCC C/C++ compiler on Debian 12 “Bookworm”.
Topic of Contents:
- Updating the Debian 12 Package Database Cache
- Installing the GCC C/C++ Compiler on Debian 12
- Testing If the GCC Compiler Is Installed Correctly on Debian 12
- Installing the Older Version of the GCC C/C++ Compiler on Debian 12
- Conclusion
Updating the Debian 12 Package Database Cache
To update the Debian 12 package database cache, run the following command:
The Debian 12 package database cache should be updated.
Installing the GCC C/C++ Compiler on Debian 12
To install the GCC C/C++ compiler and the necessary build tools on Debian 12, run the following command:
To confirm the installation, press Y and then press <Enter>.
GCC and the necessary build tools are being downloaded from the internet. It takes a while to complete.
GCC and the necessary build tools are being installed. It takes a while to complete.
At this point, the GCC C/C++ compiler and the necessary build tools should be installed on your Debian 12 machine.
Testing If the GCC Compiler Is Installed Correctly on Debian 12
Once the GCC C/C++ compiler is installed, you can run the following commands from a terminal to check whether you can access them:
$ g++ --version
As you can see, the GCC C/C++ compiler version 12.2.0 is installed on our Debian 12 machine.
Installing the Older Version of the GCC C/C++ Compiler on Debian 12
Debian 12 installs the GCC C/C++ compiler version 12 by default. If you need an older version of the GCC C/C++ compiler, you can install the GCC C/C++ compiler version 11 on your Debian 12 machine.
To install the GCC C/C++ compiler version 11 on Debian 12, run the following command:
To confirm the installation, press Y and then press <Enter>.
The GCC C/C++ compiler version 11 and the necessary build tools are being downloaded from the internet. It takes a while to complete.
The GCC C/C++ compiler version 11 and the necessary build tools are being installed. It takes a while to complete.
At this point, the GCC C/C++ compiler version 11 should be installed on your Debian 12 machine.
As you can see, the GCC C/C++ compiler version 11.3.0 is installed on our Debian 12 machine.
$ g++ --version
Conclusion
We showed you how to install the GCC C/C++ compiler version 12 on Debian 12. We also showed you how to install the GCC C/C++ compiler version 11 on Debian 12.