C++ software setup: Linux edition
Step 1: install the Clang compiler
As described in this week's lessons, in CS70 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 begin, open a terminal. The exact name of the terminal app in Linux varies by distro, but it's usually something like "Terminal", "Console", or "Konsole".
Next, in the terminal, we will use the built-in package manager to install Clang. If you're not familiar with the concept, a package manager is a tool in Linux that is used to install system-level software, such as compilers. Once again, the exact terminology will differ by distro, but the general syntax will look similar:
For Ubuntu (and Ubuntu derivatives such as Mint and Pop!OS), run the following command in the terminal:
sudo apt install clang
For Fedora / Red Hat, run the following command in the terminal:
sudo dnf install clang
For Arch Linux (and Arch derivatives such as CachyOS), run the following command in the terminal:
sudo pacman -S clang libc++
What this command does is it tells the package manager (apt, dnf, pacman, etc.) to install the package named clang (in the case of Arch Linux we also need to install a separate package called libc++, which provides the C++ standard library; this step should be done automatically for the other distros).
When you run the command, you will be prompted for your password. Remember, this is all happening on your own computer, so it wants the password you normally use to log in to your computer, not your HMC or CS70 server password! Note that when you are typing in your password, nothing will actually get shown on screen; this is by design and is not a bug, so don't be alarmed!
To test whether the installation worked, run the following command in the terminal:
clang++ --help
This should print a massive chunk of documentation for the Clang compiler, which should start with something like the following:
OVERVIEW: clang LLVM compiler
USAGE: clang [options] file...
OPTIONS:
Step 2: install Git
The process for installing Git is very similar. Just run the same command as you did before, but replace clang with git (Arch Linux users should also drop the libc++ part). This makes sense, since we're just invoking the package manager again but instead telling it we want the package named git.
As before, test that Git is working by running the following:
git --help
This should print a help summary which starts with something like the following:
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--config-env=<name>=<envvar>] <command> [<args>]
(When logged in, completion status appears here.)