Installing VS Code (Windows)



As mentioned in Lecture, we'd like you to target the C++03 standard during the first half of the semester. The standard Visual Studio (Visual C++) compiler does not allow you to do this. As such we are recommending that you download Microsoft Visual Studio Code (VSCode) and use the GCC (G++) compiler which does allow for targeting C++03.

Some of you may already have VSCode installed for other classes, so if you already have a version installed you shouldn't need to download another copy. But if you do need to download a version of VSCode, please go to https://code.visualstudio.com/download

You should see the following:

01-DownloadVSCode


Click on the "64 bit" button for System Installed (Windows). The .exe file (installer) will begin downloading. When done, you should see that the VSCodeSetup-x64.exe file has been downloaded (Google Chrome browser shown here):



02-Downloaded


Open up the VSCodeSetup-64.exe. You will likely be asked the following question:


03-Installing

Click "Yes" and begin the installation process:


04-Installing

After a few dialog boxes similar to the one shown above, you will see the following:


05-Installing

Click on the "Create a desktop icon" and then click "Next":



06-Installing


Click "Install" to continue the installation process. When installation is completed, VS Code will launch. You'll be presented with the first of a few configuration screens.

07-SetUpVSCode

Make your selections, and then click "Next Section". After you've completed the configuration screens, you will see the VS Code window shown.

Before continuing in VSCode, you'll need to get the VS Code C++ Extension. Using Chrome or some other browser, go to https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools. You should see the following:



08-FindVSCodeExtension



Click on the "Install" button. You will see the following:



09-InstallExtensionInVSCode

Click on the "Install" button on this screen. The extension will be installed and you will see the following:


10-CPPExtensionInstalle


The next step will be to find and install the GCC compiler.


The easiest place to find GCC(G++) is to go to https://winlibs.com. You should see the following:


20-WinLibsDotCom

Scroll down to the "Releases section":

21-WinLibsDownloads


Choose GCC 12.2.0… in the UCRT Runtime section and grab the Win64 version in .zip archive (don't choose the one that says "without LLVM/Clang…"

Your browser should confirm when the file is downloaded:



22-WinLibsDownloaded

Find the downloaded file in File Explorer:

24-ExtractAll

And then right click on the archive and choose "Extract All":


25-Extract


You may want to extract to a Folder at the root level of your C drive; sometimes spaces in any part of the file path can cause problems.




26-Extracted

Once extracted, you should see a mingw64 folder in whatever directory you asked to to extract to. Remember this path!

Now, go to your system settings (for Windows):


27-Settings


In the "Find a setting" field, type in "Environment":


28-EditEnvVars

In the popup menu that results, select "Edit environment variables for your account":


29-Path


Select "Path" and click "Edit"


30-EditEnvVar


In the window above, click "New":


31-New



Then click "Browse":



32-FindBinAndClickOK


Find the "bin" directory in the GCC folder that you just downloaded/extracted, select it and then click "OK":



33-BinAdded


You should now see the bin directory in the list of paths. Remember, you may not want to use a directory with a space in it. (My "Ron DiNapoli" folder could cause problems later).

Next, we have to adjust some settings in VS Code. WARNING: My results with this have been varied, so I will likely be editing these instructions in the future. But, for now, do the following:


In the lower left hand corner of the VSCode window, find the "Cog" icon which, when you hover over it, says "Manage". Select to bring up a pop up menu and then choose "Settings". You should see the following:


35-SetCPPStandard

Open up the "Extensions" dropdown (as shown above) and then select "C/C++". You should be able to scroll down and fine "Default: CPP Standard" (you can probably also search for it as well). Use the popup to select "C++03".

Next, to be "safe", while still in the Settings screen, search for "compiler" and fine the "C_Cpp > Default: Compiler Args" setting. Add "-std=c++03" and click "OK".

36-AddCompilerSwitch


This should conclude your VSCode configuration.

Next, let's try and build something. Go to the File menu in VSCode and choose "New Text File…". You should see a windows such as this…

40-VSCodeNewTextFile


Go ahead and type in our standard "Hello World" program…. The go to the "Run" menu and choose "Run without Debugging"… you should see the following:




41-RunWithoutDebugging


If you see the menu option above, choose GDB/LLDB. Or you may just see the options below:


42-PickCompiler


Either way, choose "g++.exe build and debug active file…". (I have NO idea why VSCode is asking you to build and debug when you choose "Run without Debugging…"). I'll let the VSCode express clue me in when they have time!

Anyway, after gcc/g++ compiles your program, you should see the following in the TERMINAL tab:


43-ProgramOutput


And you've just built a simple program using GCC via VSCode.



NOTES AND WARNINGS



I'm not particularly happy with VSCode as a C++ development environment, but part of that is likely that I have so little experience with it that I just don't have the right instructions for a smoother experience just yet. I will attempt to get that straightened out in the coming weeks.

My experiments with the configurations that I just had you perform are that some times they flag the non-C++-03 stuff and sometimes they don't. Again, for the first assignment, that shouldn't matter, but I will try to get a more definitive set of instructions sooner rather than later.

You will also need more instructions when we get to the point where we have multiple files in a "project". This won't affect you for another week or so at which time I hope to have more instructions available!