C++ Software Setup: Windows Edition
There are a number of ways to set up a C++ development environment in Windows. But to keep things as similar as possible to the course server (which runs Linux), we will be using MSYS2.
Step 1: Install MSYS2
Download and run the installer from the MSYS2 website. You'll get an installation wizard, but you can just leave all the settings at their default values and keep hitting until the installer finishes. Once it's done, you should see a terminal window open, and you can skip to Step 3. If you didn't get a terminal window, continue to Step 2.
I already have an install of MSYS2 from something I did ages ago. Do I need to uninstall it and start over?
Nope! You can just use the existing install. But you should make sure it's up to date by following the instructions on the MSYS2 website for updating your installation.
No… I didn't install MSYS2, it was something else. Ming-something?
If you have your own working development environment, you're welcome to skip these instructions and use it (so long as you turn off all AI code completion features). But if you want to follow along with the rest of the class, we recommend using MSYS2.
Two nice things about MSYS2 are that it is a self-contained environment that won't interfere with any other development environments you have installed, and that it provides a working environment very similar to what you have on the CS 70 server.
Step 2: Opening the MSYS2 Terminal
The MSYS2 terminal is a command-line interface that allows you to run commands on your computer using exactly the same commands we use on the CS 70 server. It has a slightly strange name, “MSYS2 UCRT64”, but you can just think of it as “the MSYS2 terminal”.
Type MSYS2 UCRT64 into the Windows search bar and hit Return. You should see a terminal window open, with a prompt that looks something like this:
Melissa@Ito UCRT64 ~
$
(except that your username and machine name will be different).
Step 3: Install Clang and Other Necessary Software
As described in this week's lessons, in CS 70 we use the Clang compiler.
There are other C++ compilers out there, but we'll stick with Clang here to be consistent with what's on the server.
But you're free to look into other options on your own time!
To install Clang and the other software we need, run the following commands in the terminal:
pacman -S mingw-w64-ucrt-x86_64-clang
pacman -S mingw-w64-ucrt-x86_64-git
pacman -S openssh
pacman -S mingw-w64-ucrt-x86_64-github-cli
pacman -S mingw-w64-ucrt-x86_64-helix
Quick Explanation
That command invoking the package manager (pacman for short), a program that is used for installing system-level software such as compilers. In this case, it's telling the package manager to install
the packages for Clang (our C++ compiler), Git (our version control system), OpenSSH (which gives you the ssh command—the one you'll use to log in to the CS 70 server), GitHub CLI (a command-line interface for GitHub), and Helix (our code editor).
You may have noticed that openssh doesn't have the long mingw-w64-ucrt-x86_64- prefix that the others do. That prefix marks a package built specifically for the UCRT64 environment you're working in; OpenSSH comes from MSYS2's own shared collection, which is the same whichever environment you use, so its name is just openssh.
Wait,
ssh? I thought Homework 1 was the one that doesn't use the CS 70 server.
It is! But every assignment after this one does use the server, and
sshis how you get there—so it makes sense to installsshnow, while you have the package manager open anyway.
Note: If the package manager asks you to “make a selection”, just hit Enter to accept the default.
Checking Your Clang Installation
To test whether the installation worked, run the following command in the terminal:
clang++ --help | head
You should see the first ten lines of what's actually a massive chunk of documentation for the Clang compiler (over 1800 lines!), which should start with something like the following:
OVERVIEW: clang LLVM compiler
USAGE: clang [options] file...
OPTIONS:
Meh. Do I have to use Helix? I like VS Code better.
We wanted to show you that you can use the same terminal-based editor that we use on the server, but you are welcome to use whatever editor you like, as long as it does not have AI code completion enabled.
(When logged in, completion status appears here.)