Installing an editor / build system

On macOS with Sublime Text, install command line tools for XCode.

Pick a Build System using Command + Shift + B. This has two options: just build, or build+run. Depending on the dependencies. it might make sense to build only

  • However, for basic scripts Build + Run [Super + B], for which Sublime will give Terminal output
  • To run without re-building, select “Build only” as the build system, then build only with Super+B.

Adding modules appears to consist of just including the files on the path in a header file, similar to MATLAB

  • The MAKEFILE can include a path to an external library, if needed


A nice thread here on the basics of installing C++ packages and using make on macOS. See here

  • Standard place to install libraries is /usr/local/ and the header files go in /usr/local/include
  • However, it might be good to install somewhere else and just re-link, since it’s good to avoid polluting system folders with 3rd party stuff

Some very nice slides with the basics of C and C++

Nice demonstrations of simple physical problems in Boos

Here and more specificallyhere

A Transition Guide: Python to C++

Goldwasser, Letscher

  • Guide for learning C++ starting from Python

CS106x at Stanford

Need SUID to access old lecture notes

  • Uses a non-standard library for a lot of data structures, mainly for pedagogical purposes (simpler API). but this makes the slides harder to use as a reference (in my experience)

Installing Boost

Can just do this with Homebrew

brew install Boost

There are also detailed instructions from the official documentation here.

Brew puts the boost library under /usr/local/Cellar/boost/1.68.0_1 instead of the official instructions, which put it under /usr/local/boost/1.68.0_1

Some notes on learning C++

C++ has three variable types: pointers, values, and references

Pointers take up their own memory address; can be used to put things in and out of that address Pointers are more general than a reference because they can point to NULL Pointers can be reassigned:

Pointer example

int x = 5;
int y = 6;
int *p;
p =  &x;
p = &y;

Reference example

int x = 5; int y = 6; int &r = x;