Setting up your environment
Welcome to the most exciting step of your programming journey: setting up your environment. I remember spending an entire afternoon wrestling with my code, only to find out that the errors I was seeing were because I hadn't install everything I needed. It was not fun, and I don't want this to happen you in this course. This document serves as a guide to configure your programming programming so that 1) you have all the tools you need to dive in and start coding, and 2) you have the same environment as the one we're going to grade your programs. This way, if it runs fine in your machine, it runs fine in ours.
Note that the place where you write your program can differ from the one where you run your program. For example, you can write your code in your laptop and run it on the department's Linux server. See "Using Visual Studio Code and SSH" for more details. This guide is for setting up the environment where you will run your program. If you choose to run your code on the server and have already set up SSH, there is nothing you need to do in this guide.
You need the following software for this class:
git
ssh
make
clang
lldb
valgrind
criterion
imagemagick
You do not need to install software that's already on your machine. In general, it should not be especially critical exactly which version you have of each of these applications, as long as it's recent. If you encounter any difficulties because of an out-of-date version of an application at any point in the future, you will be able to address it easily with a package manager. We might also ask you to install more software than these items as the course progresses.
Checking installation with which
When you type which abc
in a shell, this utility tells you where the
program abc
is installed.
If it can't find abc
in your path, which abc
produces no output.
It is a quick way to verify if you have an executable installed properly,
but it cannot be used to check if a library-only package, of which
criterion
is an example, is installed properly.
Windows
On Windows computers, you will need to install WSL (the Windows Subsystem for Linux) if you haven’t already. There are instructions for installing WSL at the following URL: https://learn.microsoft.com/en-us/windows/wsl/install.
Once you are in WSL, run the following commands, if you see any errors, stop and ask us for help:
sudo apt update
, this updates the package manager;sudo apt install build-essential
, this installs essential packages;sudo apt install clang lldb valgrind libcriterion-dev imagemagick
, this installs the rest of the packages.
Verify your installation by running the following commands
You should see the version numbers displayed on terminal. The exact version is not very critical for this class since we will follow a well-established standard.MacOS
Although MacOS has a built-in Unix shell, the Terminal
app, and almost all
tools we need come out of the box, unfortunately, you can't get valgrind
on
MacOS since 10.12.
You can still install everything else and run your code locally, but to check
for memory errors/leaks, you need to use the Linux server via SSH.
We will use Homebrew as the package manager on Mac. Follow the guide on https://brew.sh to install Homebrew if you don't have it already. Then, run the following command, if you see any errors, stop and ask us for help:
Close your Terminal and open again, and then verify your installation by running the following commands
You should see the version numbers displayed on terminal. The exact version is not very critical for this class since we will follow a well-established standard.