Numerics: software installation

In computers across campus, a C++ compiler, the IDE Code::Blocks, and Notepad++ are all installed on all the computers, so you should be able to get started straight away. If you want to work on your own computer, you will need to install software. The following notes explain this for MS-Windows and also (briefly) for Linux and Macs. Please ask me for more information, but sorry, I cannot help you with phones and tablets.

Note: I rarely use MS-Windows, and do not have access to a Mac. Because most students will want to work with MS-Windows computers, and because these are by far the most difficult ones to set up and use, I have gone into rather more detail for these, but I am not an expert on them. Linux people usually know what they are doing (and what you need is all in the operating system distro anyway) but I can certainly help here if needed (just ask). Mac people can just install XCode and (optionally) Code::Blocks as well. XCode does seem to be the best option for Macs, but looks different to Code:Blocks.

In alll cases, a good text editor plus command line compiler tools is completely adequate (and this is what I prefer for my own work). I explain this in detail for MS-Windows elsewhere. XCode contains the command line tools. I don't know Macs well enough to recommend a text editor.

1. Installing the compiler and an IDE

To get started with C++ on your own computer you need a C++ compiler and (optionally) an Integrated Development Environment (IDE) or failing this an editor. An IDE is an editor combined with various scripts and templates to get you working with C++ all in one app. That sounds great but it can make things look over-complicated at first.

For these notes we will be using Code::Blocks as the IDE. When Code::Blocks is installed you should install a compiler at the same time. The main reason for suggesting Code::Blocks here is that it is a good and fairly lightweight IDE, reasonably suitable for beginners, and is available on all three major platforms (MS-Windows, Linux and Mac) so I can give some support in all three cases. However there are alternatives. If you use something else you probably will be OK but I also certainly will not be able to offer the same level of support.

You do not have to use the Code::Blocks IDE at all, but it makes sense to install it anyway because that will also get you the compiler that you definitely need.

Code::Blocks is available at http://www.codeblocks.org/.

MS-windows users will want to go to "downloads" and "download the binary release". From here it is important that you choose a version with the compiler bundled. At the time of writing the best one is codeblocks-17.12mingw-setup.exe. This is the recommended one "if unsure" on the web page.

It may be that after you have installed Code::Blocks you may need to change settings for the compiler. This happened to me once. Go to Settings -> Compiler... -> Global compiler settings -> GNU GCC Compiler -> Toolchain executables. Here, I clicked "auto-detect" which corrected the path to the MinGW compiler. It is worth making a note of this folder. (In my case it was "C:\Program Files (x86)\CodeBlocks\MinGW".) But you can always can come back here to view the location again later.

Linux users have plenty of other choices, and if you want to download and install Code::Blocks from the main site I will be happy to advise. However, note that all Linux distros already contain everything you need to get started, and your distro probably also contains Code::Blocks itself. (Any version is OK.)

The Mac support for Code::Blocks is not as good as for other systems, but there is a version for Macs, and I am sure that it will be good enough. I couldn't try it out and don't know if it contains a compiler. Mac users may prefer to use XCode (at https://developer.apple.com/xcode/) which certainly contains everything you will need. Unfortunately I do not have a Mac and have no experience of XCode, other than noting that it has been perfectly fine for students on this module in the past. Therefore I may not be able to provide as much help. Also, Code::Blocks on the Mac can probably use the compiler installed with XCode.

2. Working without an IDE

If you choose to work without an IDE (and there are many advantages of doing this, such as for example, to avoid the complicated choices you have to make on starting up a new project) you will need a compiler and editor. The compiler was already installed with Code::Blocks. There is a huge number of editors available. For MS-windows one sensible choice would be Notepad++ at https://notepad-plus-plus.org/ . (Do not use the MS-Windows notepad application: this will not be suitable.)

I installed Notepad++ on my MS-Windows 10 computer with "Notepad++ Installer 64-bit x64" and all the defaults.

Linux (and Mac?) users will already have suitable editors installed on their system, or they can choose others in the usual way, using whatever the distribution offers.

If you are on MS-Windows and you want to work from the command line (recommended, at least to start with) you need to set your PATH variable correctly.

On my MS-Windows computer, this is what I did: I clicked the windows start button (bottom left) and type "env". Then I clicked "Edit the system environment variables". From here, click "Environment Variables..." then click the item called "Path". Click edit, and type in something like "C:\Program Files (x86)\CodeBlocks\MinGW\bin" (that's the same as the location for the compiler you noted earlier with "\bin" added at the end). This is either in a new row in a table that comes up, or at the end of one single long line immediately after a semicolon. (Add the semicolon separator if needed.) When you are done press "OK" a few times.

To test, on MS-Windows, click the windows start button (bottom left) and type "cmd". Click the "Command prompt" app that comes up and type "C++" into this. You should get a warning about "no input files" and "compilation terminated". If you get the message "'C++' is not recognised as an internal or external command" then the PATH was not set correctly. To check your path, just enter "PATH" at the command line. You should see a list of folders separated by semicolons with the one you added (probably at the end).

Basically the same PATH mechanism is used in Linux and Macs, with a few details being different, such as the separator being a colon not a semicolon. But if you install a C++ compiler in Linux using your distro (this is recommended, we will be using the GCC C++ compiler here) it will already be in your path. I imagine something similar works for Macs and xcode, though I don't know the details.

For this module any C++ compiler that meets the C++ 2011 standard should suffice. On a faily recent computer, all of the above do.