Getting Started with C++ in 15-210

Working Locally versus Remotely

You have the option of working locally on your own computer or using the Andrew Linux machines or the GHC cluster machines to do your labs. Pick whichever is more comfortable for you. If you use the Andrew Linux machines or the GHC cluster machines, they have GCC 13 installed which is sufficient for all of our code. If you prefer to use your own environment, continue reading!

Setting Up Your Own Environment

Setting up your own environment will depend a little bit on your choice of operating system.

Compiler: Regardless of operating system, we recommend using GCC as your compiler since it is up to date, supports all of the latest C++ features that we rely on, and is the compiler that we test all of the labs and reference solutions on. GCC version 11 or higher should be sufficient to compile everything we write in this class.

Setting up development on Windows

For Windows, we strongly recommend using Windows Subsystem for Linux (WSL). WSL is a complete virtualized Linux environment that you can run on Windows without needing to run a virtual machine or dual boot. We won't support the native Windows toolchain, i.e., MSVC, MSBuild, etc.

You should follow the instructions linked above to install WSL along with a Linux distribution of your choice. We recommend installing the latest version of Ubuntu since that is also what we use to develop and test the labs. Once you have installed a working Linux distribution, you should install GCC by running the following inside WSL.

sudo apt update
sudo apt install g++ build-essential

That should give you everything you need to compile code for this class. If you use a distribution other than Ubuntu, it might not support apt and you will need to search up how to install GCC on that particular distribution.

Setting up development on MacOS

MacOS comes with an annoying caveat. Apple provides their own C++ compiler (AppleClang, a fork of the open-source Clang compiler). However, their support for the latest C++ features is not as complete as GCC, so it may not support everything we need. We therefore strongly recommend installing GCC on MacOS. You should be able to install it via Homebrew

brew install gcc

Unfortunately this is not quite enough. Apple actually aliases the commands gcc and g++ to run AppleClang instead of GCC! As a workaround, you need to invoke the specific GCC version you installed to actually get GCC instead of having it sneakily run AppleClang instead. For example, if you got GCC version 14, you should run g++-14 instead of just g++. After installing via Homebrew, test that your installation works and is in fact running GCC rather than AppleClang by running the following (replacing 14 with whatever version your version of Homebrew installed.)

g++-14 --version

If the output says that it's g++ and does not mention Clang, it works! If a lab handout comes with a Makefile that invokes g++, you may need to modify it to instead invoke the correct command instead, e.g., replacing g++ with g++-14 or the version you installed, so that the Makefile does not accidentally run AppleClang.

Setting up development on Linux

If you're using Ubuntu, you can install everything we need via apt:

sudo apt update
sudo apt install g++ build-essential

If you're using a different Linux distribution that does not include apt, you should look up how to install GCC on that distribution.

Editors and IDEs

This course does not require any particular editor or IDE. All labs are compiled using a lightweight simple Makefile and can be ran from any terminal/command line/shell. An editor or IDE is purely a convenience to make writing and navigating code more pleasant.

You are free to use whatever editor or IDE you are most comfortable with. Below are a few common choices that work.

VS Code

Visual Studio Code is a lightweight and popular editor with good C++ support. Many students already use it. With the C/C++ extension installed, it provides syntax highlighting, basic code navigation, and integration with WSL on Windows. Since we are using modern C++ features, you will need to ensure that VSCode is configured for C++20 or later, or it will report (false positive) syntax errors.

Note that VS Code does not replace the compiler or build system. You will still compile your code using the provided Makefile from a terminal (either inside VS Code or externally).

CLion

CLion is a full-featured C++ IDE with excellent code navigation, refactoring support, and debugging tools. It works well with GCC on Linux and macOS, and with WSL on Windows. JetBrains provides free student licenses.

If you choose to use CLion, you may need to configure it to use the system compiler and the provided Makefile rather than its default CMake-based setup.

Other Editors

Many other editors work perfectly well, including Vim, Emacs, Sublime Text, or Neovim. As long as you can edit files and run the provided Makefile from a terminal, your choice of editor will not affect how you complete the labs.