Compiler and Tools Setup
Install Compiler Toolchain
First, you will need to install a compiler - the program that will build your code once it is written. The instructions for this vary based on your platform:
PC
MinGW is the name of a project to make the gcc
compiler available on Windows. Use
this link to download the file
https://github.com/niXman/mingw-builds-binaries/releases/download/15.2.0-rt_v13-rev0/x86_64-15.2.0-release-posix-seh-ucrt-rt_v13-rev0.7z.
It is a .7z
file, which is a compressed archive similar to a .zip
file. Window 11 supports
these. If you are using Windows 10, you will need
a program that can extract .7z
files. If you do not already have one,
7-Zip is a free program that can do this.
Once downloaded, find the file in Windows Explorer. Right-click it and select
Extract All.... For the location, type: C:\
.
Once this is done, your C: drive should have a folder called mingw64
in it.
In that folder, you should see folders called bin
, opt
, lib
, etc...
Now you need to add C:\mingw64\bin
to your Path (the list of folders Windows
looks in for programs it can run). To do so, follow these
Add to the PATH
instructions.
After pressing New to add a new item to the Path, type or copy/paste in
C:\mingw64\bin
.
This video demonstrates the process:
Mac
You will need to install the following:
- XCode command line tools
- Homebrew package manager
- gcc compiler package using Homebrew
This video demonstrates what the process looks like. Everything you need to do is in the first 2:30. Refer to the written instructions below for important hints and corrections to what you see.
First, you will need to install the XCode command line development tools. You can do this either by typing a command or using the app store:
Then open the website https://brew.sh/ and copy the command shown on the page to install Homebrew. Paste it into a terminal window and press enter. To make homebrew available in your terminal, you will need to follow the instructions it shows after the installation completes. The video above shows copying and pasting 2 lines into the terminal. You may need to copy/paste 3 lines. Start with the first line it shows and continue until you have copied all the lines it shows.
Finally, install the gcc compiler by typing the following command in a terminal window:
brew install gcc
To use this compiler, you will need to type g++-15
instead of just g++
(the -15
is for the version number). Our project templates are set to do this automatically, but if you compile by hand you will need
to remember to add the -15
.
Linux
You need to install packages that contain gcc
, gdb
, and make
(among other tools).
On Ubuntu and other apt-based distros you can do this by running the following commands
in a terminal:
sudo apt update
sudo apt install build-essential
sudo apt install gdb
Then test the installation by typing g++ --version
in a terminal window. If your version
is 14.2 or higher, you should be good to go. If not, you will need to find instructions
for your specific distro to install a newer version of g++.
Testing the compiler
To confirm the compiler is installed, open a terminal window (Terminal/Power Shell/Command Prompt on Windows, Terminal on Mac). and type the following:
g++
If you get an error saying something like g++: fatal error: no input files
, you are good to
go. If you get an error saying something like g++ is not recognized as a command
, you still
need to fix your setup.
Continue to the next page to set up Visual Studio Code.