How to properly set up Visual Studio Code for C++ coding experience?

When it comes to IOI or HKOI, C++ is the language of choice for its performance. Dev-C++ is provided at the competition as a C++ IDE, but its lack of autocomplete feature makes one feels like an animal when using it. When it comes to C++ coding, Visual Studio Code is as good as it gets. Thankfully, it is also available to contestants. However it’s not the easiest to configure. Here’s a step-by-step guide to setting it up on your computer. But first, install Visual Studio Code on your computer if you haven’t already.

For Mac

For PC

Install Mingw-w64 (C++ compiler package)

First you need to install the g++ compiler and gdb debugger. (This is already done on the computers at the competition)

Mingw-w64 is the preferred option because it is the Linux development environment that your submission will be compiled under. Click on the link and install it to a folder that has no spaces in it. In other words, don’t install it to the default C:\Program Files\. Install it to C:\Mingw-w64.

Add compiler directory to PATH variable

  1. In the Windows Search box, type “env” and then choose Edit the system environment variables from the results list.
    (If you’re on Chinese Windows, you may need to switch the display language to English first.)
  2. Click into Environment Variables.
  3. Double Click on the Path Variable to edit it. It doesn’t matter whether you choose to edit User variables or System variables. Either would work.
  4. Click “Edit Text” and add C:\Mingw-w64\mingw32\bin to the end. Put a “;” before appending the above folder name to the Path variable.In Windows 10, you can just click New and add C:\Mingw-w64\mingw32\bin as an additional path.or (in Windows 7 or before)

The EASY way

  1. Download and extract it into a folder of your choosing.
  2. Close Visual Studio Code if it’s currently open. Then Launch Visual Studio Code. Choose File -> Open Folder…
  3. Open the folder you have just extracted the contents of into.
  4. If you had installed Mingw-w64 into C:\Mingw-w64 then you are done.
  5. Go into code.cpp in the editor, set a breakpoint and Hit F5 to debug!

The HARD way (If you can do this, you can set up VS Code at the competition)

Haye Chan

Computer Science major. Retired hedge fund manager who humors himself with the idea that he has more to give in the field of education.

Leave a Reply

Close Menu