DEV Community

Muhammad Bilal Mohib-ul-Nabi
Muhammad Bilal Mohib-ul-Nabi

Posted on

Configuring c/c++ on windows for VS Code.

Follow these steps to configure VS code for c/c++ on windows.

1) Installing Compiler

To install gcc compiler for windows you can use MSYS2.It consists of bundle of tools and will install gcc also.
You can download this from the link below.
msys2

Installation of MSYS2

  • Download the installer: msys2-x86_64-20211130.exe
  • Run the installer. MSYS2 requires 64 bit Windows 7 or newer.
  • Enter your desired Installation Folder (short ASCII-only path on a NTFS volume, no accents, no spaces, no symlinks, no subst or network drives, no FAT).
  • When done, tick Run MSYS2 now.
  • Once the msys2 terminal is open enter the below command
pacman -Syu
Enter fullscreen mode Exit fullscreen mode

Enter y when it asks to proceed with installation.
At the end the terminal will be closed automatically.

  • Now again run the terminal msys2 by searching from start menu. Run the following command to update the rest of the base packages.
pacman -Su
Enter fullscreen mode Exit fullscreen mode
  • Now You have to install some tools and the mingw-w64 GCC to start compiling: Run the following command to install them
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Enter fullscreen mode Exit fullscreen mode

When it asks whether default all or it allows you to enter a number.Better is press the enter key and it will install all the packages.

  • To start building using the mingw-w64 GCC, close this window and run "MSYS MinGW 64-bit" from Start menu. Now you can call make or gcc to build software for Windows.

2) Install c/c++ extension on VS code.

Top comments (0)