CSCI 221 Setting Up for C++For CS1 you probably worked a bit to get things set up on your computer so that you could program in Python. For that course, we normally ask that you install three things
If you didn’t take my version of CS1, you might find it useful to see my Homework 0 for that course. It takes you carefully through installing each of the things listed above. In any case, if you have the above items on your computer already then you are already quite close to having a decent-enough environment for developing C++ code. What’s missing is that, for C++, you need a compiler to produce runnable programs. A compiler is a tool that takes C++ source code, reads it, and builds a program that can be excecuted directly on your computer. This program that it produces is sometimes called a executable binary file, because it is just low-level machine code that is built to run directly (sometimes the word used is natively) on your specific machine. Below we give some guidelines for getting a C++ compiler on both the Windows and the Mac system. Note that there are several ways that this can be done on each system. We’ve chosen the method that has worked best for most people, maybe requires the fewest major steps, and is the most explainable. Note that there now are ways to develop C++ without a compiler. There are several sites on the web that allow you to develop and run small C++ programs. You might find these useful while you are learning the language, but you shouldn’t come to rely on them for completing the work of this course. Also, there are Jupyter notebook extensions that have a C++ interpreter that can run individual statements of the language. As the semester progresses, we might show some of these tools. Nevertheless, we think it best that you configure your own machine with a C++ compiler. In addition to C++ programming, we’d like to teach you how to use advanced tools for developing and testing C++ programs—including a debugger ( Using C++ on the Linux dumplings via SSHWe have several Linux computers on campus with all the needed software installed on them, and you will each get an account on some of them. To login to them you just need access to a computer with the Secure SHell (SSH) command line tool (though Putty is an alternative). Open up your computer’s command line and type
where At the moment, only
Once there, you can navigate around with Unix shell commands like • You can also inspect and move around files with commands like • In addition to the
and then run it with the command line
There is also the full suite of
Getting C++ on WindowsSummary Note: I’ve heard from people that Step 0 may no longer be necessary. Description To install a WSL open up the Microsoft Store and search for Linux. This will bring up several Linux distributions as applications that you can download. Select the Ubuntu one and install it. Alternatively, you can probably just search directly for “Ubuntu” in the store. Once you’ve downloaded that software application, go ahead and run it. (Should this not work for some reason, see “Changing System Settings…”) Running the Ubuntu WSL brings up a Unix console window, one that will (because it is your first time running it) ask you to name your Linux user and provide their password. I recommend using your Reed login name and password here, mimicking what you would need if this were one of our dumpling machines, but you can choose whatever you like. This username/password combo will be what you type in whenever you rerun this Linux Ubuntu application. The Linux user you’ve created is the system administrator for this Linux subsystem. There are some configuration commands that you’ll need to run with the command prefix You’ll now want to configure the system so that it has the developer software we need. First type the command
This will make sure that your Ubuntu Linux system gets all the latest versions of the packages installed on that subsystem. Having done this, you can now install the necessary software with the command line
This installs those four Linux packages (after the word Now you should be able to work here just as you did on the dumplings. Furthermore, you can actually have access to the files you work on through the normal Windows system. Any file you save within your Windows system on your main drive (usually
and that will create a link under your Linux Ubuntu user’s home that is actually instead that Windows folder on your Desktop. So any editor you use (SublimeText, VScode, Atom, Notepad++) can be used to create and edit C++ source files, just as you normally would as a Windows user, and then you can use Linux Ubuntu’s command line to compile and run this code within the Ubuntu app’s command line. You can also, in Ubuntu, use Git commands to manage your submission repos for this class. Changing System Settings to Allow WSL References Getting C++ on the MacSummary The Mac OS X operating system makes aspects of getting Unix-like tools needed for this class similarly easy. OS X has, as its underlayer, a flavor of the Unix operating system (like Linux distributions are) and so the system comes with an application named Terminal that, when run, allows you to type the same set of commands that we listed under the Dumplingsguid just above. Furthermore, when you run this application the system will place you within your Mac user’s home folder (typically at Even so, you still need to explicitly turn on the development tools in your Mac’s system in order to get the full features we need for this course. These all are provided as part of Xcode, Mac’s free development environment for building Mac applications (and also iOS apps, etc.) Xcode is a bit too feature-rich for our purposes— we aren’t writing production-quality applications as part of this course— but it does happen to provide a C++ compiler, debugging tools, and the Git command line tools, among other useful things. Xcode has been has been provided for free in various forms since 10.3, though in some cases you had to install it explicitly from a DVD. Most recently, you install it explicitly through the Mac’s App Store. Most importantly, you want to make sure you’ve installed/enabled the Command Line Tools for Xcode. The easiest documented way I’ve found for doing this is to, in Terminal, type the command
This does the actual work of downloading additional tools and then putting them on your machine. (Alternatively, on some versions of OS X, you can select a checkbox named either “command line tools” or "Unix development support, depending, to include them with the Xcode installation.) In any case, this will include a C++ compiler, the Git command suite, Terminal-based editors like Note that you may need to restart the Terminal application to use them, after you’ve performed the installation. I have a much older Mac laptop so, at the time I installed Xcode, I wanted to be sure I had access to other command-line tools that I was used to having on Linux (that is, I installed things at a time when Apple made things less easy for me). I chose, then, to install HomeBrew which is a Ubuntu-like Unix package manager for the Mac system. You might consider installing this, as well. It’s documentation pages and install scripts seem to work to get you the Unix command line tools, as well. A competing system to HomeBrew, MacPorts also has a useful guide to installing Xcode, etc. See my list just below for reference. References |