How To Run C++?

There are many ways to compile and run C++ programs. For this course, we'll be running text-based standard C++ programs, so there should be no requirement for any particular platform. Below are several ways to acquire a free C++ compiler, create programs, and run them.

Run Linux

C was developed to run Unix, and there is a long historical connection. One of best ways to use C++ is in its home, on the Unix clone known and Linux. Linux is a free OS having many distributors, each of which gives a slightly different flavor to their version. I'm fond of Fedora, but Ubuntu seems to be the most popular for desktop right now. You can install a Linux distro on your hard drive instead of your Windows (Linux is better anyway), or beside it in a dual boot configuration. But the easiest is to simply install on a thumb drive. You don't need much space for this; 16G (or probably less is plenty). See the links above for instructions.

Once installed, use the standard software installation tool to add the C++ compiler. (I hope no one has started calling this an app store, since everything is free.)

A Unix purest will skip Linux and install BSD, which is a true descendant of the original Unix. I have not done this, so you would be mostly on your own.

Run on Windows

The simplest way to get a C++ compiler on Windows is probably to get Code::Blocks. A single install provides an IDE and compiler. You will see several versions; make sure to select the the one for mingw-setup, which provides the compiler and an install script that gets things set up nicely.

CodeBlocks does not have a current Mac version, though they do link some old ones. Not sure you want that.

An alternative is MSYS, which installs a C++ compiler suite to be run from the command line. This might be a bit more work to get installed, but running from the command line is more flexible that being boxed into some IDE. If you install this, you will also want to have a good text editor, such as Notepad++.

You probably have JGrasp installed from 116 or 216. It can compile C++ programs, if it can find the compiler. You will need add your compiler to your Windows system path to make this work. This page explains how to do this with a MinGW like MSYS. If you have CodeBlocks, the procedure is the same except that CodeBlocks installs the compiler in a different place. In the posted link (Step 4 of the path setting procedure), instead of directory C:\MinGW\bin, use C:\Program Files\CodeBlocks\MinGW\bin. Once you get the path updated and can run g++ from a standard Windows command line, then JGrasp can find the command and compile C++ programs.

Finally, you can pick one from the first menu, and one from the second, by enabling Windows Linux subsystem, and running Linux under Windows. Here's a howto on that.

Using A Mac

I don't have access to a Mac, so I can't be of much help. Here's a randomly-Googled link that may or may not be of any use. You can Google additional random links as needed.

No matter which of these approaches you use, you will using one of two compiler packages. Linux uses the GNU Compiler Collection (GCC), which has the gcc C compiler and g++ C++ compiler. MinGW, which can be installed by itself or as part of MSYS or CodeBlocks is a Windows port of GCC. This name is derived from “Minimal GNU Windows”. (Minimal is probably meant to contrast with other projects intended to implement a large part of the Unix environment under Windows.) GNU certainly runs on Mac, but the semi-official compiler set for Mac is LLVM, with the Clang C/C++ compiler. It's usually installed to work like gcc, using the same command syntax, to keep users happy and existing development environments from breaking.

GCC can be installed on Mac. LLVM can run Linux, and presumably Windows (though I've never looked it up), so these associations are not fixed, but you must never underestimate the Power Of The Default. There are other compilers, especially for C, but GCC is still the big kid on the block. LLVM is newer, and well-regarded, having taken some of the right lessons from its predecessors, so it's not going anywhere. C++ is a beastly difficult language to compile. None of which makes much difference for an introductory C++ course.