g++
Here's some more detailed instructions on the compiler for this class. Specifically, you need to have, at minimum
g++
(version 4.8.2 or newer) and
make
installed on your machine. If you have
g++
installed, run
g++ --version
to make sure you have a sufficiently recent version.
If you have a Linux installation you're comfortable using, make sure you've installed the packages containing g++ and make (it's almost certain that make is already installed.
The college also has a Linux lab in the W.E.B. which you can access either in person or remotely. See this page for specific instructions. (Please read even if you already have experience using the Linux lab machines.)
Probably the easiest way to install these tools on a Mac is to use HomeBrew. Note that you may need to install some elements of XCode in order to use HomeBrew.
Once you've installed HomeBrew, run two commands:
brew install gcc
and
brew install make
.
Then you need to make sure the HomeBrew versions are the ones you actually run. Edit the file called
.bash_profile
. At the top, add a few lines:
# to access Homebrew packages export PATH=/usr/local/bin:$PATH alias g++='/usr/local/bin/g++-7' alias make='/usr/local/bin/gmake'
To ensure everything is working right, run
g++ --version
and
make --version
. You should see g++ at least version 7 and make version at least 4.2.1.
For Windows, it seems like the most straightforward approach is to use Win-Builds. Click on the "Download and Installation" link, and Windows, and you'll end up here.
Click on "Win-Builds 1.5.0" and run the executable that downloads. Pick "Native windows" and "i686", and, as it asks, install in a new directory, like C:\Win-builds
. When the GUI application runs, you'll have the option of picking which packages to install. It's easiest just to install everything (and click the "Process" button), but if you're short on space and want to do a minimal install you just need the
gcc
, gcc-g++
, and make
packages.
The final step is to add C:\Win-builds\bin
to your Path
environment variable; how exactly to do that depends on your version of Windows; this quick guide seems comprehensive. (Please note: I'm not really a Windows guy).
g++
Once you've installed g++
and make
, you need to be able to use them! If you're unfamiliar with make
, first read An Introduction to Makefiles from the make
manual. This tutorial also walks you through a useful example.
The makefile discussion may give you enough of an idea about how to use g++
, but for more details, read the GCC manual ("GCC" stands for Gnu Compiler Collection). In particular, Chapter 7 talk about how specifically to compile a C++ program; Chapter 2 gives more general information about the compilations process. Also note that for this class, you must always compile with the std=c++11
flag.