CS 3 (Spring 2021) Software Setup: Windows

Installing Visual Studio Code

Start by downloading VSCode here: https://code.visualstudio.com/download, then follow the instructions to install it. Once it finishes, search for blank.caltech-vscode-extension-pack in the extensions view (Ctrl+Shift+X), and install the extension pack that comes up.

Installing CS 3 Depedencies

In the “explorer” tab of VSCode (the top button on the left, the icon looks like two pieces of paper), there will be an option to “Clone Repository”. Note that if you already have a folder open, you will not see this option, so you will need to close the folder first. Once you’ve clicked “Clone Repository”, type in https://gitlab.caltech.edu/cs3/msvc into the box that pops up. Find and select the directory C:\Users\USERNAME where USERNAME is your windows username.

Now, add C:\Users\USERNAME\msvc\bin to your PATH. Go to Start -> Settings -> System -> About -> Advanced system settings -> Environment Variables, or else search “Edit the system environment variables” in the search bar, then select Environment variables. Select Path under System Variables, then ‘Edit…’, then New, then paste in C:\Users\USERNAME\msvc\bin, then hit OK on all open windows. You have now properly configured your path.

Next, download Visual Studio Community from https://visualstudio.microsoft.com/downloads and run the downloaded file. If prompted, allow it to make changes to your device. Click ‘Continue’ to configure the installation, then after it downloads, click ‘Install’ at the bottom right of the window that pops up. If it asks if you want to continue without workloads, click ‘Continue’. Visual Studio Community will now install.

Within the Visual Studio Installer, you should now see ‘Visual Studio Community 2019’ under the ‘Installed’ tab, under which you should click “More -> Import Configuration”. Select the file C:\Users\USERNAME\msvc\.vsconfig, click “Review details”, and then click “Modify”. The files will now download and install. This step may take a while. You may want to uncheck “Start after installation”.

Setup Gitlab for CS 3

In the “explorer” tab of VSCode (the top button on the left, same as above), there will be an option to “Clone Repository”. Type in https://gitlab.caltech.edu/cs3/hello-world/ into the box that pops up. It does not matter where you put this repository on your computer, so if it asks for a location, you can put it wherever you want. You might be asked for a username and password; if you are, you will need to generate a “token” (as your password) on https://gitlab.caltech.edu/profile/personal_access_tokens (when generating the token, make sure to click the “API” box). The username is should be your Access username and the “password” is the token that gitlab provides you. Make sure the “remember” box is checked or save the token somewhere.

Now that the project is created in VSCode, we’re ready to run a simple C program.

First, type (Ctrl+~) to open up a terminal. When you open the terminal, you should be prompted in the lower right corner with “Do you want to allow this workspace to modify your terminal shell?”. Click “Allow”. If you click “Disallow”, you will have to delete and re-clone the hello-world repo! (This is not hard, just delete the folder containing the hello-world project and go back to the beginning of “Setup Gitlab for CS 3”. You do not have to repeat any steps before that).

Now, close the terminal (make sure to close it by clicking the trashcan icon at the right side of the terminal to kill the current terminal, rather than just minimizing it with Crtl+~). A picture of the icon is shown below:

trash

Reopen the terminal by typing (Crtl+~) again. The terminal should look different than before.

Now, type the command

cl.exe hello.c

Then, finally:

./hello.exe

to run the program. If it prints out “Hello World”, you are good to go!

Frequently Asked Questions

Question: I have gone through all the instructions, but when I try to run the ‘cl.exe’ or ‘make’ commands, I get an error saying the command is unrecognized. What should I do?

Answer: This is most likely an issue with your path. In the VSCode terminal, run the command echo $env:Path. You should get a wall of text that pops up, this represents all paths that your computer recognizes. Listed should be C:\Users\USERNAME\msvc\bin. (If you have trouble reading it, feel free to copy the output into a document and (Crtl+f) for ‘msvc’).

If you do not see the path listed, we will add it now. Open your Path by following the instructions below: Go to Start -> Settings -> System -> About -> Advanced system settings -> Environment Variables, or else search “Edit the system environment variables” in the search bar, then select Environment variables. Select Path under System Variables, then ‘Edit…’. A list of your current paths should pop up. Look for C:\Users\USERNAME\msvc\bin, and add it if it is not there in the way specified below (or edit it if it is not the exact path listed here.) Now that you’ve added it to your Path, close all instances of VSCode, then reopen it and try running ‘make’ or ‘cl.exe’ (whichever was failing before). If the problem persists, check your path again with echo $env:Path. If it is still not there, restart your computer, and try again. If you still do not see the path, please reach out to a TA for assistance.

If you do see the path, please go through all of the instructions on this sheet one more time to confirm you’ve done everything. If you are sure you have done everything listed, please reach out to a TA and they can help you.