Setting up the software for the CS 11 C track can be surprisingly complicated. The reason for this is that C is a low-level language that is very close to the operating system, and there are a lot of different operating systems (Linux, Mac, Windows, etc.). This document will help you figure out the best approach for your computer.

Prerequisite

You must know what operating system your computer runs. We are only going to support Windows, Mac, and Linux in this course. Our instructions are specific to each operating system.

We are going to assume that you know basic Unix commands (like creating and navigating directories), or that you can quickly learn them. We assume a Unix-like environment; this is the default on Linux and MacOS. For Windows you have to do a bit more work.

Linux

If your computer runs some kind of Linux, you are in luck! You can just use your computer’s package manager to install all the software for the course. For instance, on Ubuntu Linux, you can do:

$ sudo apt update
$ sudo apt install gcc make gdb

and then you have the gcc C compiler, the make program, and the gdb debugger, all of which we’ll be using. (The $ is a prompt; don’t type that.)

On other Linux distributions, the commands may be different, but if you use Linux, you probably know how to use your package manager.

Windows

If your computer runs Windows, you need to install the Windows Subsystem for Linux. This will install a version of Ubuntu Linux inside of Windows. The great thing about this is that you can edit your C code inside Visual Studio Code (VS Code) and run it inside a terminal inside VS Code. You just have to make sure that when you select the terminal to run inside VS code that you choose the Ubuntu terminal and not the Windows Powershell terminal.

MacOS

To compile C code on a Mac, you need to install the command-line tools. This will provide you with a C compiler and other tools, such as the make program we will discuss starting in lecture 2. You can invoke the C compiler as gcc, but it is actually a different compiler called clang. For the most part, clang is compatible with gcc and takes the same command-line options.

Instead of the gdb debugger, on a Mac you use a debugger called lldb. Instructions on how to use it are on this page. Again, it’s feature-compatible with gdb, though some commands will have different names and/or may work slightly differently. A very useful reference is this site, which shows you what the equivalent commands are in both gdb and lldb.