Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up a C/C++ Development Environment in Visual Studio Code

Tech 2

Visual Studio Code (VS Code) is a lightweight, cross-platform source code editor developed by Microsoft. It runs on Windows, macOS, and Linux, offering consistent functionality across operating systems. Built-in features such as syntax highlighting, intelligent code completion, bracket matching, and customizable keybindings enhance developer productivity.

While VS Code supports many languages out of the box, C/C++ support is added via extensinos. Combined with an external compiler like GCC, it becomes a capable environment for C/C++ development.

Installing VS Code

Download and install VS Code from the official website: https://code.visualstudio.com/

Installing a C/C++ Compiler

On Windows, MinGW-w64 provides a complete GCC toolchain. Download it from:

https://sourceforge.net/projects/mingw-w64/files/

Choose any recent version for Windows, then extract the archive. For example, extract to:

F:\ProgramSoftware\GCC\mingw64

Configuring Environment Variables

Add the compiler’s bin directory to your system’s PATH:

  1. Copy the path: F:\ProgramSoftware\GCC\mingw64\bin
  2. Open System Environment Variables
  3. Edit the Path variable under System variables
  4. Add a new entry with the copied path
  5. Save and restart any open terminals

Verifying the Setup

Create a test file named hello.cpp:

#include <iostream>

int main() {
    std::cout << "Hello, C++!" << std::endl;
    return 0;
}

Open a terminal in VS Code and run:

g++ hello.cpp -o hello
./hello

If the output displays Hello, C++!, the environment is correctly configured.

Best Practices

Avoid using integrated build buttons or tasks for simple projects during initial setup. Instead, compile and run manually via the terminal to ensure full control and visibility over the build process.

Tags: vscodeC++

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.