Ancient CS 61 Content Warning!!!!!1!!!
This is not the current version of the class.
This site was automatically translated from a wiki. The translation may have introduced mistakes (and the content might have been wrong to begin with).

Infrastructure

Download the CS61 Virtual Machine

You will need the CS61 virtual machine for some assignments. You may wish to use it for all assignments as it has been pre-populated with some of the tools we think you'll need during the semester. Most problem sets can also be run on other Linux machines or Mac OS X machines. However, we recommend you at least check your work on the course VM, in case you are accidentally relying on Mac-specific behavior.

Install a virtual machine monitor (VMM)

If you wish to run the course virtual appliance, you will need a virtual machine monitor -- we recommend VirtualBox, but if you already have either VMware Fusion (Mac) or VMware Workstation (Linux or Windows), you should be able to use them. You should however make sure that you are running the latest version of your VMM (version 8 for Fusion; version 12 for Workstation).

You can obtain VirtualBox for Mac (OSX), Windows, or Linux here.

Using VirtualBox

Linux

Prerequisites

VirtualBox setup

At this point, you're now ready to import the CS61 Appliance. Download it from here.

Mac OS X

At this point, you're now ready to import the CS61 Appliance. Download it from here.

Windows

Running the CS61 VM with VMWare

Mac OSX (VMware Fusion 8)

You are now ready to import the CS61 Appliance (Virtual Machine or VM) into VMware Fusion.

Windows (VMware Workstation 12)

You are now ready to import the CS61 Appliance (Virtual Machine or VM) into VMware Workstation.

Linux (VMware Workstation 12)

You are now ready to import the CS61 Appliance (Virtual Machine or VM) into VMware Workstation.

Updating your compiler

The CS61 VM, unfortunately, has a relatively old compiler (GCC-4.8). Here’s how to upgrade the CS61 VM to GCC-6, a more modern compiler.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-6 50

On Mac OS X, install a newer compiler with Homebrew. I've installed the gcc-6 package. Then you can specify a specific compiler like so:

make SANITIZE=1 CC=gcc-6

Version control with Git

We will be using git with GitHub Classroom for turning in problem set submissions and version control.

What is git?

Git was developed by Linus Torvalds for development of the Linux kernel. It’s is a distributed version control system, which means it supports many local repositories which each track changes and can synchronize with each other in a peer-to-peer fashion. It’s the best widely-available version control system, and certainly the most widely used. For information on how to use git, see:

Cloning the problem set repository

Problem sets will be released using the cs61/cs61-psets repository.

Please click this link to create your own private clone of the problem sets repository. You’ll clone that repository onto your computer, do work there, and then push your work upstream to the GitHub-hosted repository for us to grade.

Here’s how it should work.

  1. Click the link.
  2. Log in to GitHub, or create an account.
  3. The link should automagically clone the repository. For instance, if your account name was kohler-dumb, you should get a repository called cs61/cs61-f16-psets-kohler-dumb.

Working with a partner? No problem. Find out their GitHub username, and then add them to your repository as a collaborator using Settings > Collaborators & teams.

Teaching GitHub about your identity

The easiest way to access GitHub repositories is using an SSH key, a secret key stored on your CS61 VM that defines your identity. This handy HCS tutorial may be useful to teach you about SSH; or just follow the steps below to create a key for your virtual machine.

  1. Launch your VM and open a terminal.
  2. Run ssh-keygen -t rsa -b 2048 and follow the instructions.
    • Press enter to use the default file path and key name (should be ~/.ssh/id_rsa).
    • Choose a password or leave it empty.

This creates your ssh keys, which live in the directory ~/.ssh. Your public key is in the file ~/.ssh/id_rsa.pub.

Finally, tell GitHub about this key.

  1. Run cat .ssh/id_rsa.pub to display your public key.
  2. Copy your public key (that is, select the text on the screen, and copy it to the clipboard).
  3. In GitHub, go to your profile settings page (accessible via the upper-rightmost link—this looks like a bunch of pixels for new accounts). Select “SSH and GPG keys” and hit the “New SSH key” button. Then copy and paste the contents of your ~/.ssh/id_rsa.pub file into the “Key” section. Give the key a sensible title, hit the “Add SSH key” button, and you’re good to go.

Creating a local clone

Once GitHub knows your SSH identity, you’re ready to clone your problem set repository and start doing work! Here’s how to get a local copy of the repo on your machine:

     git config --global user.name "FIRST_NAME LAST_NAME"
     git config --global user.email "YOUR_@COLLEGE_EMAIL"
     git clone REPO_URL

where REPO_URL is the URL for your repository. This will be something like git@github.com:cs61/cs61-f16-psets-yourname.git, and can be obtained on GitHub by clicking the “Clown or download” button. You want to clone using SSH, not HTTPS, so you might need to click “Use SSH”.

Troubleshooting

If you are having any trouble with your keys (e.g., you cannot clone a repo because "the connection timed out"), check if your firewall is blocking port 22, and open port 22 if it is blocked. You can use your favorite search engine to figure out how to do this.

Obtaining future problem sets

The following should be done every time a new pset is released or an old pset is updated.

This will download the latest pset directory into your repo.

Another way that’s convenient long-term is to add a handout remote to your repository. That works like this:

 git remote add handout git://github.com/cs61/cs61-psets.git

Now you can:

Submitting problem sets

Be sure that git status (from your “cs61-f16-psets-yourname” directory) reports that you have no uncommitted changes.

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

If git status reports that you have uncommitted changes, you'll need to commit these changes! Read through our Git tutorial for details.

Then, run git push, and be sure Git reports that everything is up-to-date:

$ git push
Everything up-to-date

Head over to the grading server and make sure that your code passes all tests you expect it to. The first time you visit the grading server, enter your official email address for the username (that will be your college.harvard.edu address if you are a college student and the email address you used when you registered for the class if you are an extension student. Then request a password reset. Once you've got your password, you can log into the grading server and enter the URL of your repository.

Obtaining lecture code

The code we’ll look at in lecture, and the lecture exercises, is available at the beginning of lecture in a public Git repository. Here’s how to obtain it the first time:

     git clone git://github.com/cs61/cs61-exercises.git

This will put the lecture code in a directory called cs61-exercises.

To update exercise code for a new lecture, change into that directory and run git pull