Open-access mathematical research insights
About Contact
Home / Free Stuff

C++ Setup Guide

Get your computer ready to run the prime number programs

About the Programs

Throughout the free stuff section you will see topics with (C++). These topics include a code block that you can run locally on your terminal. They would all run equally well in Python, but as you get to very large numbers (and you might if you're interested), there is no competition - you need C++.

All the programs were tested on a 2019 MacBook (2.3 GHz 8-Core Intel Core i9; 16 GB 2667 MHz DDR4). They all run fine on any modern computer.

macOS Setup

Terminal
# Install Xcode Command Line Tools (includes g++)
xcode-select --install

# Verify installation
g++ --version

# Optional: Install GMP for large number support
brew install gmp

Windows Setup

PowerShell
# Download and install MSYS2 from https://www.msys2.org/

# After installation, open MSYS2 terminal and run:
pacman -Syu
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-gmp

# Add to PATH: C:\msys64\mingw64\bin

Linux Setup

Terminal (Ubuntu/Debian)
# Install build essentials
sudo apt install build-essential

# Install GMP for large number support
sudo apt install libgmp-dev
Terminal (Fedora)
# Install development tools
sudo dnf groupinstall "Development Tools"

# Install GMP
sudo dnf install gmp-devel
Terminal (Arch)
# Install base development
sudo pacman -S base-devel

# Install GMP
sudo pacman -S gmp

Compiling Programs

Terminal
# Basic compilation
g++ -o program program.cpp

# With optimizations (recommended for large computations)
g++ -O2 -o program program.cpp

# With GMP library (for programs using large integers)
g++ -o program program.cpp -lgmp -lgmpxx

# With debug symbols
g++ -g -o program program.cpp

Programs on This Site

Stay Updated

Get weekly digests of new research insights delivered to your inbox.