Installing C/C++ Compiler on Windows 10/11
Having a C/C++ compiler on your Windows 10 or 11 machine is essential for anyone interested in C/C++ programming. In this tutorial, we'll guide you through the process of installing a C/C++ compiler on your Windows 10/11 computer, whether you're a beginner or an experienced programmer looking to set up a development environment.
Why Do You Need a C++ Compiler?
Before we start the installation process, let's briefly understand why having a C++ compiler is crucial. A C++ compiler is a tool that translates your C++ code into machine code that your computer can understand and execute. This is necessary to turn your programming ideas into functional software applications. With a C++ compiler, you can write, compile, and run C++ programs to build a wide range of applications.
Choosing a C++ Compiler
There are several C++ compilers available for Windows, but one of the most popular and versatile options is the GNU Compiler Collection (GCC), which includes the g++ compiler for C++. It's free and open-source, making it an excellent choice for beginners and experts alike.
Step-by-Step Guide to Installing a C/C++ Compiler on Windows 10/11
- Download MinGW:
- Installation MinGW:
- Add MinGW to Your System PATH:
- Verify the Installation:
- Download and Set up Visual Studio Code IDE:
MinGW is a free, open-source development environment for creating Windows applications, offering compilers for C and C++, among other tools. It generates 32-bit executables compatible with both 32-bit and 64-bit Windows. Download the MinGW .exe installer here.
Run the downloaded installer, and a graphical installer will appear on your screen. Follow the installation process until it is complete. Keep the installation directory default as shown in the image below:
When you see MinGW Installation Manager window, mark all the packages for installation as shown in the image below:
Go to Installation in the top menu and select Apply Changes, as shown in the image below:
On the next window, choose the Apply button and wait the installation to complete.
After the installation is complete, you need to add the MinGW bin directory to your system's PATH environment variable. To do this, navigate to the MinGW installation directory and copy the location of the MinGW bin directory (C:\MinGW\bin), as shown in the image below:
To access System Properties, type "env" in the Windows search bar and select the Edit the system environment variables shortcut, as shown in the image below:
On the System Properties window, click the Environment Variables button. Under System variables, select Path and click the Edit button to set the path for MinGW. Next, click the New button and paste the location of the MinGW bin directory (For example: C:\MinGW\bin) that you copied earlier, as shown in the image below:
Click the OK button.
Open a Command Prompt or PowerShell window and type g++ --version. You should see information about the installed g++ compiler, confirming that it's installed correctly.
Visit the official website of Visual Studio Code at https://code.visualstudio.com/download and download the installer for your operating system.
Launch Visual Studio Code after the installation is complete.
Next, go to Visual Studio Code Extensions and install C/C++ by Microsoft and Code Runner by Jun Han.