What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To build and debug C or C++ in Visual Studio Code, install the editor extension plus a compiler and a compatible debugger for your operating system. The C/C++ extension adds features such as IntelliSense, code navigation, and error checking, but it does not include the compiler or debugger. Microsoft describes VS Code as relying on command-line tools for the development workflow in its C/C++ documentation.

What you need for a working C/C++ setup

A complete development loop has four parts: source code, a compiler to turn it into an executable, a build configuration that tells the compiler what to do, and a debugger to inspect the running program. VS Code is the editor and coordination layer; installing its C/C++ extension alone does not provide the other tools.

  • VS Code: the editor.
  • Microsoft C/C++ extension: language services, including IntelliSense completions and hovers, plus error checking.
  • Compiler and build tools: for example, MSVC, GCC, or Clang, selected to suit your platform and project.
  • Debugger: for example, the Visual Studio Windows Debugger, GDB, or LLDB, depending on the toolchain.

Microsoft’s platform-specific tutorials are collected in its C/C++ documentation and tutorials. Choose the route that matches your operating system, course, or workplace requirements rather than expecting one toolchain to be best for every setup.

Choose a setup route for your operating system

Environment Common tutorial toolchain Debugger considerations Useful for
Windows Microsoft C++ (MSVC) or MinGW/GCC Use the Visual Studio Windows Debugger with the corresponding MSVC workflow, or GDB for a MinGW/Cygwin setup. A GDB configuration may need an explicit path to gdb.exe in miDebuggerPath. Native Windows development; select the route required by your project or course.
Linux GCC, typically g++ GDB is the official tutorial’s debugger path. Linux development. On Ubuntu, GCC and GDB are not installed by default, so follow your distribution’s install instructions.
Windows Subsystem for Linux (WSL) GCC in the Linux environment Follow the WSL-specific workflow and use the VS Code WSL remote workflow when the project files live in WSL. Working with source files and tools hosted in the WSL environment.
macOS Clang/LLVM Use LLDB or GDB as appropriate for the selected toolchain. Apple command-line developer tools can provide Clang. Native macOS development using the Clang/LLVM workflow.
Linux project built with CMake The project’s CMake configuration and chosen compiler Use the debugger supported by the compiler and environment, commonly GDB in the Linux tutorial path. Projects where the build is managed by CMake rather than a one-file task.

These are tutorial routes, not a promise that every compiler or debugger is bundled with the editor. Microsoft documents debugger choices and platform limitations in Debug C++ in Visual Studio Code.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install and verify the command-line toolchain

  1. Install VS Code and the C/C++ extension. The extension supplies editor language features, not the build and debug executables.
  2. Install the compiler and debugger for the selected route. On Linux, use the package instructions for your distribution. On macOS, Apple command-line developer tools can make Clang available. On Windows, follow either the MSVC or MinGW/GCC tutorial, according to your needs.
  3. Open VS Code in the environment where the source files and tools are located. For WSL-hosted files, use the WSL workflow rather than treating the Linux toolchain as if it were installed on Windows.
  4. Check compiler discovery in the integrated terminal. Try g++ --version for GCC or clang --version for Clang. A version response indicates that the shell can locate that command; it does not by itself verify the debugger or project build.
  5. If the command is not found, check installation and PATH. If it is installed but VS Code does not discover it, review PATH and the C/C++ compiler configuration. Microsoft’s C/C++ FAQ covers compiler configuration and related setup issues.

Build a simple program

For a basic single-file tutorial, the C/C++ flow can detect a compiler and create a default build task. A task records the build command and its settings in tasks.json. Microsoft’s macOS Clang walkthrough shows this build-and-launch configuration pattern in Using Clang in Visual Studio Code.

  1. Create or open a small .c or .cpp source file in the VS Code workspace.
  2. Use the C/C++ workflow to select or detect the compiler, then build the active file using the generated task where available.
  3. Read the terminal output. If compilation fails, fix the reported source or configuration error before trying to run the program.
  4. Run the resulting executable using the build task or the launch configuration appropriate to the tutorial and toolchain.

A generated task is a convenient starting point, not a universal build system. It does not automatically describe every multi-file application, library, compiler option, or production build.

Configure debugging

Building and debugging use separate configurations. tasks.json describes how to build; launch.json describes how to start a debugging session. A launch configuration can specify the executable, arguments, working directory, debugger mode, and a pre-launch build task.

  1. Build the program with the selected toolchain and ensure it produces an executable with the debug information needed by that debugger.
  2. Create or select the platform-appropriate launch configuration. Choose the matching debugger: Windows Debugger or GDB for the applicable Windows setup, GDB on Linux, or LLDB/GDB on macOS.
  3. Set the executable and any needed arguments or working directory in launch.json.
  4. If the program should rebuild before debugging, set preLaunchTask to the exact label of the corresponding build task in tasks.json.
  5. Start debugging and set a breakpoint in the source. If the debugger cannot find the executable or attach useful source information, verify the executable path, the selected debugger, and the compiler’s debug-symbol settings.

For MinGW or Cygwin GDB on Windows, the debugger executable may not be discoverable automatically; set miDebuggerPath to the correct gdb.exe when required. Debug-symbol flags depend on the compiler, so use documentation for the chosen toolchain. Microsoft’s FAQ and debugger documentation describe these configuration concerns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Adapt the setup for multi-file and CMake projects

When a project contains several source files or has a defined build system, configure VS Code around the project’s actual build rather than relying on an active-file task. Microsoft’s C/C++ tutorial set includes a CMake Tools path for Linux, and its FAQ identifies compile_commands.json as an option when the project’s build system can generate a compilation database.

  • Use the project’s prescribed build system and compiler settings; do not replace them with a one-file task unless the project is genuinely that simple.
  • For CMake projects, follow the CMake-oriented workflow and its project configuration.
  • For projects that generate a compilation database, configure the C/C++ extension to use that database so editor language services can account for the project’s compile commands.

Use a remote or isolated development environment when appropriate

Local development does not require remote extensions. If the code or toolchain is hosted elsewhere, Microsoft documents supported workflows using Remote – SSH, Dev Containers, and WSL. Install and use the corresponding extension for the environment that owns the files and tools; the same distinction between editor, compiler, build configuration, and debugger still applies. See Microsoft’s C/C++ documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common setup problems

  • The extension is installed but no compiler is found: install a compiler separately and check that its executable is available on PATH or selected in the C/C++ configuration.
  • The build task runs but debugging does not start: check that launch.json points to the built executable and that its debugger matches the toolchain.
  • VS Code says a pre-launch task is missing: make the preLaunchTask value match the build task’s label exactly.
  • GDB cannot be located on Windows: provide the correct gdb.exe path through miDebuggerPath when using a MinGW/Cygwin workflow.
  • Breakpoints do not behave as expected: confirm the executable was built with debug information supported by the compiler and that the debugger corresponds to that toolchain.
  • Editor errors do not match the project build: verify compiler configuration or, for a supported build system, use its compilation database so the extension can see the project’s actual compile commands.

Continue learning

If your goal is to learn C++ itself rather than install the environment, Standard C++ lists learning books, including C++ Primer, on its Get Started page. A book is optional and is not part of the VS Code setup.

Best Value

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.