Lab 0: Setting up your computer to compile in C++

This is an introductory lab for setting up your computer. It is important to be able to do this, as using online compilers are very limiting on how you can use them, and will teach you bad coding practices that will do more harm than good.

Task A: Installing the compiler

For Windows Users

There are two different approaches to setting up.

Approach 01 (Preferred)

  1. Install MinGW. The Download link can be found here: https://sourceforge.net/projects/mingw/files/. Make sure to write down the location where you installed it!
  2. Go to your control panel. Click System, and go to advanced system settings. click on enviromental variables at the bottom right
  3. Go to Path in System variables and click it.
  4. Click New, and write down the location of MinGW. Also be sure to add "\bin" at the end. The final location should be something like "PATH\TO\MinGW\bin"
  5. Once done. You need to open MinGW. Go to basic setup, and select "mingw32-gcc-g++-bin" or similar. Then Mark for installation. After that, go to installation (top left) and press "Apply changes". After it finishes, you should have g++.
After doing this, you want to install git.
  1. The download link can be found here: https://git-scm.com/downloads. Make sure you install git bash
  2. Once done, you can use git bash as your main terminal, using UNIX commands to navigae through.

Approach 02

Follow this guide: https://okunhardt.github.io/documents/Installing_WSL.pdf

For Mac Users

Download and install XCode from the app store. This will handle pretty much anything so far. Although, it is recommended that you use a different text editor.

If Mac cannot install XCode

  1. Install Homebrew: https://brew.sh/
  2. Once Installed, try running "brew install gcc". This should work. If there is any issues with installation, try adding 'sudo' to the beginning of your command (i.e: "sudo brew install gcc"). This will ask for your password as the 'sudo' command has the highest privilege and overrides many safeguards. Be careful when using it!!

Task B: testing to make sure your compiler works

Create a new file, and use the hello world program to make sure compiling works.

Alternatively, simply typing 'g++ --version' on terminal / git bash / command prompt, and receiving information about it means that you have successfully installed it.