Setting up a GNU Development Environment

In this course we will be using the GNU toolchain for building our C/C++ programs. A toolchain is a group of programs that is used to develop and test software. If you really want to use a different toolchain (e.g. Microsoft VisualStudio or XCode), I’m not going to stop you. However, the only toolchain officially supported is going to be GNU. If you choose to use something else, I may or may not be able to help you figure out why your code isn’t building but I can make no guarantees.

There are a few reasons for using the GNU toolchain as opposed to MSVC, Xcode, etc:

What follows are instructions for getting the GNU toolchain installed and working on Windows, MacOS, and Linux. Once you have the GNU toolchain installed, go ahead and try to build the Hello World program to try out your newly-installed compiler.

Windows

To write software in Windows you will need three things: A text editor, the GNU compiler toolchain, and enough of a Unix system for the GNU build tools to work. For the latter two, we will be using a system called MinGW.

Text Editors

An important part of any programming setup is a decent text editor. There are a number of good ones for windows. Most of the lab and office computers have WinEdt installed. Another good text editor for windows is Notepad++. The two most important things about your text editor is that it has syntax highlighting and decent handling of indentation. If you’re not sure what I mean, just install Notepad++ and you’ll figure it out soon enough.

MinGW

MinGW or “Minimalist GNU for Windows” is a project that provides the GNU toolchain and just enough other standard Unix tools to be able to build software. Because the GNU compiler toolchain is designed to work in a Unix environment and windows isn’t Unix-based, you need just a little more than just the compilers. Fortunately, the MinGW project has all of this bundled into a easy-to-use installer. To install MinGW, do the following:

Once MinGW has installed, you will have an entry for MinGW in your Start Menu. Under this is a program called “MinGW Shell.” This provides you a basic Unix shell from which you can run compilers and other things.

MacOS

Many Mac users don’t know this, but MacOS is really a Unix system at heart. While it has a nice fancy Apple-branded user interface, it’s running Berkeley UNIX under the hood. This makes it very nice to work with once we coax it into installing the GNU toolchain. Again, this isn’t that hard:

Text Editors

An important part of any programming setup is a decent text editor. There are a lot of good text editors out there. One option is to use the text editor built into Xcode. Even though we will be using the command line for compiling our programs, you can still use the text editor in Xcode. Another option is TextWrangler which is a nice, basic, programmer’s text editor.

Linux

Linux is based on the GNU toolchain, so installing it is very simple if it isn’t installed already. Simply use your package manager to install gcc, g++, and make. You will also need to install a decent text editor like Vim, gedit, or Kate.