C++ Development Configuration (Windows)

Before writing code in C++, there’s a bit of configuration that needs to be done.

VS Code

VS Code is the program we’ll be using to write all of our code. The standard version can be downloaded here, but we’ll be using the version made specifically for FRC programming. To download this software, scroll down on the WPILib releases page until you find something that looks like this:

Be sure to look for the most recent release; the year and version numbers may not match with the picture above.

If you’re using a 64-bit Windows computer (you probably are, but click here to see how to check), click on the file containing “Windows64.” If you’re using a 32-bit Windows computer, click on the file containing “Windows32.” Then save the download anywhere on your computer.

Once that finishes downloading, double click on the “.iso” file and then double click on “WPILibInstaller.exe.” You should now see this screen:

Press “Start,” and then click “Download VS Code for Single Install.” Then press “Next.” On the next screen, make sure all items are checked and then press “Install for this User.” Once this finishes, you should find VS Code along with some other robotics software on your computer’s desktop. If you don’t see VS Code there, you can also find it by going to the start menu and searching “VS Code”.

C++ Compiler

The compiler is what’s used to convert the code you write into a program your computer can run. To run your C++ code, you’ll need to download a C++ compiler that is compatible with your computer. The below steps should work as long as you’re using Windows. Otherwise, you can find additional options that are compatible with VS Code here.

  • Download MinGW-w64 (just a set of programming tools, including a C++ compiler) here, where you should be prompted to download the program.
  • Open the downloaded .exe file and complete the MinGW installation process.
    • If you’re on a 64 bit computer you can change the “i686” chipset option to “x86_64”. All other settings should be left to their defaults.
    • Keep note of your MinGW installation location; that will be used later.
  • After installation is complete (it will probably take several minutes), you need to let your computer know where its C++ compiler is located. This is done by updating your computer’s “Path” variable, which is nothing but a set of important file locations.
  • Open up the start menu and type “environment variables”. There should be an option called “Edit the system environment variables” (or something similar), which you should open.
  • Click on the button labeled “Environment Variables…”
  • Find the Path variable and double click it.
  • Click “Browse” and find the location of your MinGW installation. Then, within MinGW’s folder find a folder called “bin”. Click on it and then press “Ok”.
    • My bin folder’s path is: “C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin”, so yours may look similar.
  • Press Ok on all of the other windows you just opened to save your changes.

Configuring VS Code

Choose a place to store your C++ projects, and create a folder there (named anything) for your first program. Then, open VS Code, click “File” and then “Open Folder…” and choose the folder you created.

Now we need to configure VS Code for C++ programming. Press Ctrl + Shift + P to open up the command list and type “C/C++”. Click on the option labeled “C/C++: Edit Configurations (UI)”.

Under the “Compiler path” setting, make sure the path is set to your MinGW g++.exe file.

(My exact path may look slightly different from yours. Just make sure it ends in “g++.exe”.)

Also, set the “IntelliSense mode” setting to “gcc-x64” (if you are using a 64 bit computer, “gcc-x86” if not). Then you can close out of all the tabs that are opened.

One other thing I find helpful in VS Code is auto save. You can enable this by pressing Ctrl + Shift + P and typing “auto save”. Then press “File: Toggle Auto Save.”

Test Code

Now it’s finally time to write some code!

In VS Code’s explorer tab, click the “New File” button next to the name of your folder (mine is called “Hello World”), and name this new file “main.cpp”.

Now copy the below code into main.cpp (I’ll go over what all this code means on the next page.):

#include <iostream>

int main() {
    std::cout << "Hello world!\n";
    return 0;

To compile your code (to convert it to a form readable by your computer), press Ctrl + Shift + P and find “C/C++: Build and Debug Active File”. Click on that, and then click “g++.exe – Build and debug active file”. After doing this, you’ll always be able to compile your code by simply pressing Ctrl + Shift + B.

Now the code is compiled, and you should see a file called “main.exe” in the explorer tab. To run this file, make sure you have “cmd” selected as your current terminal by looking at the top right of your terminal tab. If the terminal is not opened, press Ctrl + ` (that second character is the backtick, on the same key as the tilde).

If “cmd” is not currently selected, you can press “Select Default Shell” and then select “Command Prompt”.

From the terminal, you can now type “.\main.exe” and your program will run! You should see “Hello world!” appear on your screen.

Later in this guide I’ll provide lots of example programs for you to try out. Just remember that, to run these programs, you’ll need to follow the steps below:

  • Compile the program by pressing Ctrl + Shift + B
  • Navigate to the Command Prompt and run the program by typing “.\main.exe

To make this process a little easier, you can press the play button on the left activity bar and then press “Run and Debug”:

Then select the proper environment, which will probably look like C++ (GDB/LLDB), and then choose the g++.exe compiler. Now, you should be able to both compile and run your program just by pressing on the green play button at the top of the menu: