Setting up the C++ Environment (Windows)
Last Updated on: 3rd Dec 2025 19:08:51 PM
C++ is a powerful and versatile programming language, but before you can start writing and running programs, it’s essential to set up your development environment correctly. Visual Studio Code (VS Code) is one of the most popular choices for C++ development due to its lightweight design, fast performance, and rich extension support.
While there are many tools available for writing C++ programs, in this tutorial we will focus on two widely used options:
-
Dev-C++ – a simple and beginner-friendly IDE.
-
Visual Studio Code (VS Code) – a modern, flexible code editor suitable for both beginners and advanced developers.
This overview will guide you through these environments so you can easily choose and configure the right setup for your C++ journey.
Prerequisites
-
A Windows PC (Windows 7 / 8 / 10 / 11).
-
Administrator access to install software.
-
Internet connection to download installers.
Dev-C++ (step-by-step)
Step 1 : Which Dev-C++?
There are several builds (old Bloodshed, Orwell, Embarcadero). For most users choose Embarcadero Dev-C++ or a maintained fork that includes MinGW/GCC.
Step 2 : Download
-
Open your browser and search "Embarcadero Dev-C++ download" (or the maintained fork).
-
Or Click here to Download the installer (usually .exe).
Step 3 : Run the installer
-
Double-click the downloaded .exe file.
-
Accept User Account Control if prompted.
-
Follow the setup wizard: Accept license, choose installation folder (default
C:\Program Files\Dev-Cppis fine). -
During the install, ensure the option to install MinGW/GCC is selected (if present). This installs g++, gcc, gdb.
Step 4 : First launch and verify compiler
-
Open Dev-C++.
-
Create a new file:
File → New → Source File. -
Save it as
hello.cpp. -
Paste the following code:
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
return 0;
}
-
Compile and run:
Execute → Compile & Run(or press the play/compile icon). -
If compilation fails, open Tools → Compiler Options and ensure the compiler executable path points to the included MinGW
binfolder (e.g.,C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\bin).
Step 5 : Verify inside Dev-C++
-
Open Dev-C++
-
Go to Tools → Compiler Options
-
Click the Compiler set to configure
-
At the top it will show something like:
TDM-GCC 9.2.0 64-bit Release
This confirms Dev-C++ is using TDM-GCC 9.2.0.
Method 2 — Verify using Command Prompt
-
Press Win + R, type cmd, hit Enter
-
Type:
g++ --version
You should see output similar to:
g++ (tdm64-1) 9.2.0
Built by MinGW-W64 project
If you get:
'g++' is not recognized...
Then Dev-C++'s GCC is not added to the PATH. In that case:
► How to use correct path:
Find the folder:
C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\bin
Then run:
"C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\bin" --version
This will show:
g++ (tdm64-1) 9.2.0
Method 3 — Compile a test program
-
Create hello.cpp:
#include <iostream>
int main() {
std::cout << "Compiler OK\n";
}
-
In Dev-C++, click Compile & Run
If it compiles successfully without error, your TDM-GCC 9.2.0 is working correctly.
Step 6 : Configure basic editor preferences (optional but recommended)
-
Tools → Editor Options to change font, tab size (set tab to 4 spaces), and enable line numbers.
-
Tools → Compiler Options to set language standard (if available) — choose C++11/C++14/C++17 depending on version.
Setting Up the C++ Environment in Visual Studio Code (VS Code) – Complete Tutorial
Step 1 : Install Visual Studio Code
-
Visit the official VS Code website
-
Download Windows → User Installer (x64)
-
Install with all default settings.
Step 2 : Install MinGW-w64 (C++ Compiler)
To compile C++ programs, you need a compiler like GCC/G++.
Step-by-step:
-
Go to the official MinGW-w64 page
https://winlibs.com/ -
Download:
"MinGW-w64 GCC x86_64 (latest stable version)" -
Extract the downloaded ZIP file.
-
Copy the extracted folder to
C:\mingw-w64
Step 3 : Add MinGW Compiler to System PATH
So that g++ can run from any folder.
-
Press Windows + R → type sysdm.cpl
-
Go to the Advanced tab → Environment Variables
-
In System Variables, select Path → click Edit
-
Click New and add:
D:\Software\mingw64\bin
- Click OK to save.
Step 4 : Verify Installation
Open Command Prompt and type:
g++ --version
If it shows version details → compiler is installed correctly.
Step 5 : Install Required VS Code Extensions
Open VS Code → go to Extensions (Ctrl+Shift+X)
Install these:
-
C/C++ (by Microsoft)
-
Code Runner (optional, for quick run)
-
C/C++ Compile Run (optional)
Step 6 : Create Your First C++ Program in VS Code
-
Create a folder
Example:C:\CPP_Projects -
Open the folder in VS Code:
-
File → Open Folder
-
-
Create a new file:
hello.cpp -
Write:
#include <iostream>
using namespace std;
int main() {
cout << "Welcome to C++ Programming!" << endl;
return 0;
}
Step 7 : Run C++ Program (Two Methods)
Method 1: Run using Terminal (Recommended)
-
Open VS Code terminal
Ctrl + ` -
Compile:
g++ hello.cpp -o hello.exe
- Run:
hello.exe
Method 2: Run using Code Runner (Optional)
Click Run Code button on top.
Note: Code Runner may not support input (
cin) correctly.
8. Configure Build & Run Tasks (Automatic Compile + Run)
To run C++ with a single key (Ctrl+Shift+B):
Create tasks.json
-
Go to:
Terminal → Configure Default Build Task
-
Select: C/C++ g++.exe build active file
This will generate a tasks.json file in .vscode folder.
Your C++ Environment in VS Code Is Ready!
Now you can write, compile, debug, and run C++ programs efficiently using VS Code.
Keep practicing — you're doing amazing!
Happy Coding! ![]()